Пример #1
0
 def __init__(self, ticker):
     self.ticker = ticker
     params = getParams(ticker)
     self.mean = params[0][0]
     self.var = params[0][1]
     self.vol = params[1]
     self.price = get_price(self.ticker)
Пример #2
0
async def consumer(message, socket, socketID):
  global cameraParameters
  global isSendingVideo

  data = json.loads(message)
  if data['type'] == 'get camera params':
    await socket.send(json.dumps({'type': 'camera params', 'params': params.getParams()}))

  elif data['type'] == 'set camera param':
    params.setParam(data['name'], data['value'], cameraParameters)
    if (data['name'] == 'camera id'):
      init_camera()

  elif data['type'] == 'send video':
    videoClients.add(socketID)
  
  elif data['type'] == 'stop video':
    videoClients.remove(socketID)

  elif data['type'] == 'get input config':
    config = 'ERROR NO CONFIG'
    if (os.path.isfile('configs/inputs.txt')):
      file = open('configs/inputs.txt', 'r') 
      config = file.read()

    message = json.dumps({'type': 'input config', 'config': config })
    await socket.send(message)

  elif data['type'] == 'set input config':
    # write data['config'] to file
    file = open('configs/inputs.txt', 'w')
    file.write(data['config'])
    file.close()
Пример #3
0
def train(dataset_dir, augment=False, pretrained_coco=False):
    """Train the model"""

    config = FBSConfig()

    dataset_train = FBSDataset()
    dataset_train.load_data(dataset_dir, subset='train')
    dataset_train.prepare()

    dataset_val = FBSDataset()
    dataset_val.load_data(dataset_dir, subset='validate')
    dataset_val.prepare()

    augmentation = None
    if augment:
        augmentation = iaa.SomeOf((0, 6), [
            iaa.Fliplr(0.5),
            iaa.Flipud(0.5),
            iaa.OneOf([
                iaa.Affine(rotate=90),
                iaa.Affine(rotate=180),
                iaa.Affine(rotate=270)
            ]),
            iaa.Multiply((0.8, 1.5)),
            iaa.GaussianBlur(sigma=(0.0, 2.0))
        ])

    model = modellib.MaskRCNN(mode='training',
                              config=config,
                              model_dir=DEFAULT_MODEL_DIR)

    params = getParams('Mask_RCNN')
    epochs = params['epochs']

    #TODO remove useless callbacks

    if pretrained_coco:
        COCO_MODEL_PATH = 'mask_rcnn_coco.h5'
        model.load_weights(COCO_MODEL_PATH,
                           by_name=True,
                           exclude=[
                               "mrcnn_class_logits", "mrcnn_bbox_fc",
                               "mrcnn_bbox", "mrcnn_mask"
                           ])

    model.train(dataset_train,
                dataset_val,
                learning_rate=config.LEARNING_RATE,
                epochs=10,
                augmentation=augmentation,
                layers='heads')

    model.train(dataset_train,
                dataset_val,
                learning_rate=config.LEARNING_RATE,
                epochs=25,
                augmentation=augmentation,
                layers='all')
Пример #4
0
def train(dataset_dir, augment=False, pretrained_coco=False):
    """Train the model"""

    config = FBSConfig()
    config.display()
    dataset_train = FBSDataset()
    dataset_train.load_data(dataset_dir, subset='train')
    dataset_train.prepare()

    dataset_val = FBSDataset()
    dataset_val.load_data(dataset_dir, subset='validate')
    dataset_val.prepare()

    augmentation = None
    if augment:
        augmentation = iaa.SomeOf((0, 6), [
            iaa.Fliplr(0.5),
            iaa.Flipud(0.5),
            iaa.OneOf([
                iaa.Affine(rotate=90),
                iaa.Affine(rotate=180),
                iaa.Affine(rotate=270)
            ])
        ])

    model = modellib.MaskRCNN(mode='training',
                              config=config,
                              model_dir=DEFAULT_MODEL_DIR)

    params = getParams('Mask_RCNN')
    epochs = params['epochs']

    if pretrained_coco:
        COCO_MODEL_PATH = 'mask_rcnn_coco.h5'
        model.load_weights(COCO_MODEL_PATH,
                           by_name=True,
                           exclude=[
                               "conv1", "mrcnn_class_logits", "mrcnn_bbox_fc",
                               "mrcnn_bbox", "mrcnn_mask"
                           ])

    # model_path = model.find_last()

    # # Load trained weights
    # print("Loading weights from ", model_path)
    # model.load_weights(model_path, by_name=True)

    model.train(dataset_train,
                dataset_val,
                learning_rate=config.LEARNING_RATE,
                epochs=70,
                augmentation=augmentation,
                save_best_only=True,
                monitored_quantity='val_mrcnn_mask_loss',
                layers='all')
Пример #5
0
def getNotifications(type):
    params = getParams(type)
    collectionRef = db.collection('{}-notifications'.format(type))

    account = getAccount(type)
    browser = login(type, account)
    browser.open(params['notifsUrl'])
    soup = browser.parsed

    ul = soup.find('ul', attrs={'class': 'timeline'})

    if not ul:
        raise ValueError("Couldn't open Notifications page")

    li_time_label = ul.find_all('li', attrs={'class': 'time-label'})
    div_timeline_item = ul.find_all('div', attrs={'class': 'timeline-item'})

    for i in range(len(li_time_label)):
        date = li_time_label[i].text.strip(' \t\n\r')
        time = div_timeline_item[i].span.text.strip(' \t\n\r').replace(
            '&nbsp', '').replace(';', '')
        heading = div_timeline_item[i].find('h4',
                                            attrs={
                                                'class': 'timeline-header'
                                            }).text.strip(' \t\n\r')
        body = div_timeline_item[i].find('div',
                                         attrs={
                                             'class': 'timeline-body'
                                         }).text
        poster = div_timeline_item[i].find('h3',
                                           attrs={
                                               'class': 'timeline-header up'
                                           }).text.strip(' \t\n\r')
        poster = poster[len('Posted by : \n              \n              '):]
        key = '{} : {} : {}'.format(getHash(date + time + heading + body[:5]),
                                    date, time)

        docRef = collectionRef.document(key)
        if not docRef.get().exists:
            docRef.set({
                'key': key,
                'date': date,
                'time': time,
                'heading': heading,
                'body': body,
                'poster': poster
            })
            sendMessage(label=type,
                        message=notificationTemplate(date, time, heading, body,
                                                     poster))
    return '{} notifications parsed'.format(type)
Пример #6
0
def login(type, account):
    params = getParams(type)
    browser = RoboBrowser(history=True, parser='html.parser')
    browser.open(params['loginUrl'])
    form = browser.get_form(0)

    if not form:
        raise ValueError("Couldn't login")

    form[params['username_field']].value = account['username']
    form[params['password_field']].value = account['password']
    browser.submit_form(form)
    browser.open(params['notifsUrl'])
    soup = browser.parsed
    ul = soup.find('ul', attrs={'class': 'timeline'})
    return True if ul else False
Пример #7
0
def findAccount(type):
    params = getParams(type)
    branches = [
        'CO', 'SE', 'IT', 'EC', 'EL', 'EE', 'CE', 'PS', 'BT', 'EP', 'MC', 'ME',
        'AM', 'PE', 'EN'
    ]
    for branch in branches:
        for i in range(1, 100):
            rollno = '00' + str(i) if i < 10 else '0' + str(i)
            account = {
                'username': params['year'] + '/' + branch + '/' + rollno,
                'password': '******'
            }
            print("Trying with account: {}".format(account['username']))
            if login(type, account):
                return account
Пример #8
0
def login(type, account):
    params = getParams(type)
    browser = RoboBrowser(history=True, parser='html.parser')
    browser.open(params['loginUrl'])
    form = browser.get_form(0)

    if not form:
        raise ValueError("Couldn't login")

    form[params['username_field']].value = account['username']
    form[params['password_field']].value = account['password']
    browser.submit_form(form)
    browser.open(params['notifsUrl'])

    print('Logged in with account: {}'.format(account))

    return browser
Пример #9
0
def getJobs(type):
    params = getParams(type)
    collectionRef = db.collection('{}-jobs'.format(type))

    account = getAccount(type)
    browser = login(type, account)

    browser.open(params['jobsUrl'])
    soup = browser.parsed

    table_jobopenings = soup.find('table', attrs={'id': 'jobs_search'})

    if not table_jobopenings:
        raise ValueError("Couldn't open jobs page")

    trs = table_jobopenings.find_all('tr')

    for i in range(1, len(trs)):
        tds = trs[i].find_all('td')
        if tds[3].find('i')['class'][1] == 'fa-check':
            name = tds[0].text
            appDeadline = tds[2].text
            dateOfVisit = tds[6].text
            link = trs[i]['onclick'].replace("void window.open('",
                                             '').replace("')", '')

            docRef = collectionRef.document(name)
            if not docRef.get().exists:
                docRef.set({
                    'name': name,
                    'appDeadline': appDeadline,
                    'dateOfVisit': dateOfVisit,
                    'link': link,
                })
                sendMessage(label=type,
                            message=jobTemplate(name, appDeadline, dateOfVisit,
                                                link))

    return '{} jobs parsed'.format(type)
Пример #10
0
dataset_train = BrainDataset()
dataset_train.load_brain_data('../../data/train/images/*',
                              '../../data/train/masks/*')
dataset_train.prepare()

dataset_val = BrainDataset()
dataset_val.load_brain_data('../../data/test/images/*',
                            '../../data/test/masks/*')
dataset_val.prepare()

LOG_DIR = os.path.join(ROOT_DIR, 'logs')
MODEL_DIR = os.path.join(LOG_DIR, "mask_rcnn")
model = modellib.MaskRCNN(mode='training', config=config, model_dir=MODEL_DIR)

params = getParams('Mask_RCNN')

epochs = params['epochs']
Checkpoint, EarlyStop, ReduceLR, Logger, TenBoard = getCallbacks(params)

# COCO_MODEL_PATH = 'mask_rcnn_coco.h5'
# model.load_weights(COCO_MODEL_PATH, by_name=True,
#         exclude=["mrcnn_class_logits", "mrcnn_bbox_fc",
#             "mrcnn_bbox", "mrcnn_mask"])

# augmentation = iaa.SomeOf((0, 3),[
#     iaa.Fliplr(0.5),
#     iaa.Flipud(0.5),
#     iaa.OneOf([
#         iaa.Affine(rotate=90),
#         iaa.Affine(rotate=180),
Пример #11
0
def savePreferences(*args):
    params.getParams()
    settings = utility.JsonUtility.createJsonData()
    utility.JsonUtility.write(storage.prefsFile, settings)
    utility.setAllMetadata()
Пример #12
0
    "output": False,
    "n": False,
    "r": False,
    "s": False,
    "h": False,
    "c": False,
    "l": False,
    "i": False,
    "start": False,
    "e": False,
    "missing": False,
    "all": False,
    "padding": False
}

params.getParams(parameters)
params.paramsCheck(parameters)

cols = 0
# promenna ve ktere uchovavam cislo radku
spaces = 0
# promenna ve ktere uchovavam pocet tabulatoru
head = [
]  # promenna ve ktere je ulozen prvni radek pokud je aktivni prepinac -h
x = 0  # pocitadlo prvku v hlavicce
rowCount = int(parameters["start"])


#funkce nahradi problematicke znaky
def replace(st):
    st = st.replace("&", "&amp;").replace("'", "&apos;").replace(