Spaces:
Sleeping
Sleeping
Commit
Β·
f50a656
1
Parent(s):
99b73a0
Rename init_predict_mock.py to model_mock.py and update main.py to use the Model class for predictions
Browse files
inference_utils/{init_predict.py β model.py}
RENAMED
File without changes
|
inference_utils/{init_predict_mock.py β model_mock.py}
RENAMED
@@ -23,7 +23,7 @@ class Model:
|
|
23 |
pass
|
24 |
|
25 |
def predict(
|
26 |
-
image: Image, modality_type: str, targets: list[str]
|
27 |
) -> Tuple[Image, str]:
|
28 |
# Randomly split targets into found and not found
|
29 |
targets_found = random.sample(targets, k=len(targets) // 2)
|
|
|
23 |
pass
|
24 |
|
25 |
def predict(
|
26 |
+
self, image: Image, modality_type: str, targets: list[str]
|
27 |
) -> Tuple[Image, str]:
|
28 |
# Randomly split targets into found and not found
|
29 |
targets_found = random.sample(targets, k=len(targets) // 2)
|
main.py
CHANGED
@@ -23,9 +23,9 @@ DEV_MODE = True if os.getenv("DEV_MODE") else False
|
|
23 |
import gradio as gr
|
24 |
|
25 |
if DEV_MODE:
|
26 |
-
from inference_utils.
|
27 |
else:
|
28 |
-
from inference_utils.
|
29 |
|
30 |
|
31 |
gr.set_static_paths(["assets"])
|
@@ -93,8 +93,8 @@ DEFAULT_MODALITY = "CT-Abdomen"
|
|
93 |
|
94 |
|
95 |
def run():
|
96 |
-
|
97 |
-
model
|
98 |
|
99 |
with gr.Blocks() as demo:
|
100 |
gr.Markdown("# BiomedParse Demo")
|
@@ -126,7 +126,7 @@ def run():
|
|
126 |
|
127 |
submit_btn = gr.Button("Submit")
|
128 |
submit_btn.click(
|
129 |
-
fn=predict,
|
130 |
inputs=[input_image, input_modality_type, input_targets],
|
131 |
outputs=[output_image, output_targets_not_found],
|
132 |
)
|
@@ -134,8 +134,8 @@ def run():
|
|
134 |
gr.Examples(
|
135 |
examples=examples,
|
136 |
inputs=[input_image, input_modality_type, input_targets],
|
137 |
-
outputs=output_image,
|
138 |
-
fn=predict,
|
139 |
cache_examples=False,
|
140 |
)
|
141 |
|
|
|
23 |
import gradio as gr
|
24 |
|
25 |
if DEV_MODE:
|
26 |
+
from inference_utils.model_mock import Model
|
27 |
else:
|
28 |
+
from inference_utils.model import Model
|
29 |
|
30 |
|
31 |
gr.set_static_paths(["assets"])
|
|
|
93 |
|
94 |
|
95 |
def run():
|
96 |
+
model = Model()
|
97 |
+
model.init()
|
98 |
|
99 |
with gr.Blocks() as demo:
|
100 |
gr.Markdown("# BiomedParse Demo")
|
|
|
126 |
|
127 |
submit_btn = gr.Button("Submit")
|
128 |
submit_btn.click(
|
129 |
+
fn=model.predict,
|
130 |
inputs=[input_image, input_modality_type, input_targets],
|
131 |
outputs=[output_image, output_targets_not_found],
|
132 |
)
|
|
|
134 |
gr.Examples(
|
135 |
examples=examples,
|
136 |
inputs=[input_image, input_modality_type, input_targets],
|
137 |
+
outputs=[output_image, output_targets_not_found],
|
138 |
+
fn=model.predict,
|
139 |
cache_examples=False,
|
140 |
)
|
141 |
|