Пример #1
0
def new_model(name, width, height, type):
    post('ml/model', None, {
        'name': name,
        'width': width,
        'height': height,
        'type': type
    }, opts)
Пример #2
0
def add_integration(stdr, name, type, params, opts: options.Options):
    if params is None:
        params = []
    paramsdict = {
        params[i].split("=")[0]: params[i].split("=")[1]
        for i in range(0, len(params))
    }
    print(paramsdict)
    post(f'stedr/{stdr}/integration', {}, {
        "name": name,
        "type": type,
        "params": paramsdict
    }, opts)
Пример #3
0
def image_reeval(stedr, imageid, imagelist, progress, opts):
    success = 0
    failures = 0

    if imageid is not None:
        try:
            post(f'snap/{stedr}/{imageid}/eval', None, None, opts)
        except:
            click.echo("Unable re-evaluate snap with id: " + imageid)

    else:
        if imagelist is None:
            click.echo("You must specify either snap id or a file")
            return False
        if not isfile(imagelist):
            click.echo(
                "file must be a regular file with ids separated by newline")
        if not progress:
            progress = imagelist + ".progress"
        with open(imagelist) as f:
            all_lines = [
                fileline.split(",")[0].strip() for fileline in f.readlines()
            ]
            if all_lines[0] == 'id':  # Remove header if this is a csv file
                all_lines.pop(0)
            with click.progressbar(all_lines,
                                   label='Reprocess images') as allIds:
                for imgid in allIds:
                    if not progress_already_contains_item(progress, imgid):
                        try:
                            post(f'snap/{stedr}/{imgid}/eval', None, None,
                                 opts)
                            update_progress_file(progress, imgid, True)
                            success += 1
                        except:
                            update_progress_file(progress, imgid, False)
                            failures += 1

    click.echo(f'Successfully re-evaluated {success} images')
    if failures > 0:
        click.echo(
            f'Failed re-evaluating {failures} images - see {progress} for details'
        )
Пример #4
0
def image_upload(stedr, path, reprocess, backfill, date, progress,
                 opts: options.Options):
    # Start populating request data
    # TODO proper options for backfill and reprocess
    data = {}
    params = {}
    if reprocess:
        params['reprocess'] = reprocess
    if backfill:
        params['backfill'] = backfill

    # Get all files to upload
    if isdir(path):
        if opts.verbose > 1:
            click.echo('Uploading images from %s' % path)
        onlyfiles = [f for f in listdir(path) if isfile(join(path, f))]
        with click.progressbar(onlyfiles,
                               label='Uploading images') as allfiles:
            for f in allfiles:
                if not progress_already_contains_item(progress, f):
                    try:
                        fullfile = join(path, f)
                        #populate_from_exif(fullfile, data)
                        adjustdate(data, date)
                        data['image'] = encode(fullfile)
                        post(f'snap/{stedr}', params, data, opts)
                        update_progress_file(progress, f, True)
                    except:
                        update_progress_file(progress, f, False)
    else:
        if opts.verbose > 1:
            click.echo('Uploading image %s' % path)
        if not progress_already_contains_item(progress, path):
            try:
                #populate_from_exif(path, data)
                adjustdate(data, date)
                data['image'] = encode(path)
                post(f'snap/{stedr}', params, data, opts)
                update_progress_file(progress, path, True)
            except Exception as e:
                click.echo('Error' % e)
                update_progress_file(progress, path, False)
Пример #5
0
def train_model(modelid):
    post(f'ml/model/{modelid}/train', None, None, opts)
Пример #6
0
def wordcount():
    post('dataflow/wordcount', None, {}, opts)
Пример #7
0
def remakemonth(stedr, year, month, opts: options.Options):
    if month == 0:
        for m in range(1, 13):
            post(f'timelapse/{stedr}/remakemonth/{year}/{m}', None, {}, opts)
    else:
        post(f'timelapse/{stedr}/remakemonth/{year}/{month}', None, {}, opts)
Пример #8
0
def remakeimage(stedr, year, opts: options.Options):
    post(f'timelapse/{stedr}/remakeimage/{year}', None, {}, opts)
Пример #9
0
def set_heartbeat(stdr, hours, type, id, opts: options.Options):
    post(f'stedr/{stdr}/heartbeat', {
        "hours": hours,
        "type": type,
        "id": id
    }, {}, opts)
Пример #10
0
def set_watermark(stedr, f, pos, mode, opts: options.Options):
    data = {'image': encode(f), 'mode': mode, 'position': pos}
    post(f'stedr/{stedr}/watermark', None, data, opts)
Пример #11
0
def run_cronfull(stdr, opts: options.Options):
    params = {}
    if stdr is not None:
        params["stedr"] = stdr

    post(f'cron/run', params, {}, opts)
Пример #12
0
def run_cronrules(stdr, opts: options.Options):
    post(f'cron/{stdr}/rules/run', {}, {}, opts)
Пример #13
0
def run_cronsource(stdr, count, backfill, opts: options.Options):
    post(f'cron/{stdr}/source/run', {
        "count": count,
        "backfill": backfill
    }, {}, opts)
Пример #14
0
def image_predict(stedr, snap, opts):
    post(f'snap/{stedr}/{snap}/ml', None, None, opts)
Пример #15
0
def deploy_model(modelid):
    post(f'ml/model/{modelid}/deploy', None, None, opts)
Пример #16
0
def add_rule(stdr, opts: options.Options):
    post(f'stedr/{stdr}/rule', {}, {}, opts)
Пример #17
0
def manual_model(modelid, projectid, model, version):
    post(f'ml/model/{modelid}/manual', {'projectid': projectid, 'model': model, 'version': version}, None, opts)
Пример #18
0
def image_upload_from_source(stedr, backfill, count, opts):
    params = {"count": count}
    if backfill:
        params["backfill"] = ''
    post(f'cron/{stedr}/source', params, {}, opts)