Spaces:
Sleeping
Sleeping
siriuszeina
commited on
Commit
•
476290c
1
Parent(s):
a745ac1
Update app.py
Browse files
app.py
CHANGED
@@ -43,8 +43,8 @@ def load_labels() -> list[str]:
|
|
43 |
model = load_model()
|
44 |
labels = load_labels()
|
45 |
|
46 |
-
|
47 |
-
def predict(
|
48 |
_, height, width, _ = model.input_shape
|
49 |
|
50 |
image = PIL.Image.open(BytesIO(base64.b64decode(base)))
|
@@ -78,9 +78,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
78 |
gr.Markdown(DESCRIPTION)
|
79 |
with gr.Row():
|
80 |
with gr.Column():
|
81 |
-
|
82 |
-
base = gr.Textbox("")
|
83 |
-
#img = gr.File(type="binary")
|
84 |
score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
|
85 |
run_button = gr.Button("Run")
|
86 |
with gr.Column():
|
@@ -94,7 +92,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
94 |
|
95 |
run_button.click(
|
96 |
fn=predict,
|
97 |
-
inputs=[
|
98 |
outputs=[result, result_json, result_text],
|
99 |
api_name="predict",
|
100 |
)
|
|
|
43 |
model = load_model()
|
44 |
labels = load_labels()
|
45 |
|
46 |
+
|
47 |
+
def predict(image: PIL.Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
|
48 |
_, height, width, _ = model.input_shape
|
49 |
|
50 |
image = PIL.Image.open(BytesIO(base64.b64decode(base)))
|
|
|
78 |
gr.Markdown(DESCRIPTION)
|
79 |
with gr.Row():
|
80 |
with gr.Column():
|
81 |
+
image = gr.Image(label="Input", type="pil")
|
|
|
|
|
82 |
score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
|
83 |
run_button = gr.Button("Run")
|
84 |
with gr.Column():
|
|
|
92 |
|
93 |
run_button.click(
|
94 |
fn=predict,
|
95 |
+
inputs=[image, score_threshold],
|
96 |
outputs=[result, result_json, result_text],
|
97 |
api_name="predict",
|
98 |
)
|