Esempio n. 1
0
def upload_file():
    f = request.files['image_file']
    file_path = "./app/zip_dataset/{}".format(f.filename)
    f.save(file_path)

    output_path = "./app/unzip_dataset/{}".format(
        f.filename.replace(".zip", ""))
    with zipfile.ZipFile(file_path, 'r') as zip_ref:
        zip_ref.extractall(output_path)

    file_name = f.filename.replace(".zip", "")
    source = "./app/unzip_dataset/{}/{}".format(file_name, file_name)
    destination = "./app/test_dataset/{}".format(file_name, file_name)
    dest = shutil.move(source, destination)

    global fh
    global bp
    fh = FrameHandler()
    bp = BoundingBoxPredictor(fh)

    return 'file uploaded successfully'
Esempio n. 2
0

@app.route("/predictNextFrameBoundingBoxes", methods=['POST'])
def predictNextFrameBoundingBoxes():
    json_request = request.get_json()
    fname = json_request["fname"]
    drivename, fname = fname.split("/")
    frame = fh.load_annotation(drivename, fname)
    res = bp.predict_next_frame_bounding_boxes(frame)
    keys = res.keys()
    for key in keys:
        res[str(key)] = res.pop(key)
    print(res)

    return str(res)


@app.route("/loadAnnotation", methods=['POST'])
def loadAnnotation():
    json_request = request.get_json()
    fname = json_request["fname"]
    frame = fh.load_annotation(fname)
    return str(frame.bounding_boxes)


if __name__ == "__main__":
    fh = FrameHandler()
    bp = BoundingBoxPredictor(fh)
    os.system("rm {}/*".format(os.path.join(DIR_PATH, "static/images")))
    app.run(host="127.0.0.1", port='2000')