Spaces:
Configuration error
Configuration error
Update app_1.py
Browse files
app_1.py
CHANGED
@@ -8,6 +8,20 @@ import tqdm
|
|
8 |
from label_studio_sdk.client import Client
|
9 |
from getpass import getpass
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
class ModelPredictor:
|
12 |
def __init__(self, model_name, file_to_predict_on, data_dir = "./data/preprocessed_data/", model_dir="./models/"):
|
13 |
"""
|
@@ -138,14 +152,7 @@ model_path = BASE_DIR / "models"
|
|
138 |
models = [model.name for model in model_path.iterdir() if model.is_dir()]
|
139 |
|
140 |
for model_name in models:
|
141 |
-
|
142 |
-
predictor = ModelPredictor(model_name, "validation")
|
143 |
-
predictor.predict()
|
144 |
-
|
145 |
-
# Predict on the training set example
|
146 |
-
predictor = ModelPredictor(model_name, "training")
|
147 |
-
predictor.predict()
|
148 |
-
|
149 |
# Predict on the unlabeled set example
|
150 |
predictor = ModelPredictor(model_name, "unlabeled")
|
151 |
predictor.predict()
|
@@ -333,4 +340,22 @@ def import_annotations_existing_tasks(predictions: List[Dict], label_studio_proj
|
|
333 |
print(f"Importing annotations to project {label_studio_project_id}")
|
334 |
print(project.create_predictions(prediction_for_this_project))
|
335 |
|
336 |
-
return "Annotations imported successfully."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
from label_studio_sdk.client import Client
|
9 |
from getpass import getpass
|
10 |
|
11 |
+
from huggingface_hub import login
|
12 |
+
|
13 |
+
login(token = os.getenv('HF_TOKEN'))
|
14 |
+
|
15 |
+
model_id = "RTLucassen/flan-t5-large-finetuned-melanocytic-lesion-reports"
|
16 |
+
|
17 |
+
local_dir = "models"
|
18 |
+
|
19 |
+
hf_hub_download(
|
20 |
+
repo_id=repo_id,
|
21 |
+
filename=model_id,
|
22 |
+
local_dir = local_dir
|
23 |
+
)
|
24 |
+
|
25 |
class ModelPredictor:
|
26 |
def __init__(self, model_name, file_to_predict_on, data_dir = "./data/preprocessed_data/", model_dir="./models/"):
|
27 |
"""
|
|
|
152 |
models = [model.name for model in model_path.iterdir() if model.is_dir()]
|
153 |
|
154 |
for model_name in models:
|
155 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
# Predict on the unlabeled set example
|
157 |
predictor = ModelPredictor(model_name, "unlabeled")
|
158 |
predictor.predict()
|
|
|
340 |
print(f"Importing annotations to project {label_studio_project_id}")
|
341 |
print(project.create_predictions(prediction_for_this_project))
|
342 |
|
343 |
+
return "Annotations imported successfully."
|
344 |
+
|
345 |
+
def segment_report(file):
|
346 |
+
|
347 |
+
return ''
|
348 |
+
|
349 |
+
|
350 |
+
input_files = gr.File()
|
351 |
+
|
352 |
+
iface = gr.Interface(
|
353 |
+
fn=segment_report,
|
354 |
+
inputs=input_files,
|
355 |
+
outputs=['text'],
|
356 |
+
title='Segment Reports',
|
357 |
+
description="This application helps segmenting medical report into meaningful fragments",
|
358 |
+
theme=gr.themes.Soft(),
|
359 |
+
)
|
360 |
+
|
361 |
+
iface.launch()
|