def make_pre_mask(): slide_id = request.args.get('slide_id', type=int) model_name = request.args.get('model_name', type=str, default="0") thread_controller.BackgroundThread( image_processing.predict_mask_with_job_id, slide_id, model_name).start() return jsonify({"info": "Mission Started !", "time": "-1"})
def export_freehand_annotation(): manifest_file = request.args.get('manifest_file', type=str) thread_controller.BackgroundThread( annotation_project_controller.export_freehand_annotation_data, manifest_file).start() return redirect('/annotation_project_table')
def make_region(): manifest_name = request.args.get('manifest_name', type=str) region_size = request.args.get('region_size', type=int) if os.path.exists("static/export/" + manifest_name + "_" + str(region_size) + ".zip"): os.remove("static/export/" + manifest_name + "_" + str(region_size) + ".zip") thread_controller.BackgroundThread(make_region_back, manifest_name, region_size).start() return "static/export/" + manifest_name + "_" + str( region_size) + ".zip" + "?random=" + str(uuid.uuid4())
def import_manifest(manifest_path): manifest_db = manifest.Manifest() manifest_txt = open(manifest_path).readlines() for wsi in manifest_txt: info = wsi.split('\t') if info[0] == "id": continue try: manifest_db.insert(slide_uuid=info[0], svs_file=info[1]) except Exception as e: print(e) thread_controller.BackgroundThread(manifest_controller.get_table, 0).start()
def export_region_annotation_single(): if request.method == 'GET': manifest_file = request.args.get('manifest_file', type=str) slide_id = request.args.get('slide_id', type=str) region_size = request.args.get('region_size', type=str) manifest_txt = [ item for item in open(manifest_file).readlines() if item[:len(slide_id)] == slide_id ] print(slide_id) print(manifest_file) if len(manifest_txt) == 0: return "input ERROR!!" print(manifest_txt) export_file = annotation_project_controller \ .export_region_annotation_data(manifest_file, region_size, manifest_txt) with open(export_file, 'rb') as f: data = f.readlines() os.remove(export_file) return Response(data, headers={ 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename=%s;' % (manifest_file.rsplit("/", 1)[1][:-4] + '_nuclei_annotation.zip') }) if request.method == 'POST': manifest_file = request.form.get("manifest_file") region_size = request.form.get("region_size") slide_id = request.form.getlist('slide_id[]') print(slide_id) print(manifest_file) manifest_txt = [ item for item in open(manifest_file).readlines() if item[:len(slide_id[0])] in slide_id ] if len(manifest_txt) == 0: return "input ERROR!!" print(manifest_txt) export_file = "static/export/" + time.ctime() + \ " " + manifest_file.rsplit("/", 1)[1][:-4] + " region " + str(region_size) + ".zip" thread_controller.BackgroundThread( annotation_project_controller.export_region_annotation_data, manifest_file, region_size, manifest_txt, export_file).start() return export_file
def refresh_annotation_slide(): thread_controller.BackgroundThread( annotation_project_controller.refresh_npy).start() # annotation_project_controller.refresh_npy() return redirect('/annotation_project_table')
def make_bg_mask(): slide_id = request.args.get('slide_id', type=int) thread_controller.BackgroundThread(image_processing.make_bg, slide_id).start() return jsonify({"info": "Mission Started !", "time": "5"})