Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
import json
|
3 |
import gradio as gr
|
4 |
import yolov5
|
@@ -9,13 +8,14 @@ app_title = "Football Object Detection"
|
|
9 |
models_ids = ['keremberke/yolov5n-football', 'keremberke/yolov5s-football', 'keremberke/yolov5m-football']
|
10 |
article = f"<p style='text-align: center'> <a href='https://huggingface.co/{models_ids[-1]}'>huggingface.co/{models_ids[-1]}</a> | <a href='https://huggingface.co/keremberke/football-object-detection'>huggingface.co/keremberke/football-object-detection</a> | <a href='https://github.com/keremberke/awesome-yolov5-models'>awesome-yolov5-models</a> </p>"
|
11 |
|
12 |
-
|
|
|
|
|
13 |
model = yolov5.load(current_model_id)
|
14 |
|
15 |
examples = [['test_images/18_pp_jpg.rf.912a54e24d38371daf61114b9a6b18be.jpg', 0.25, 'keremberke/yolov5m-football'], ['test_images/54881_jpg.rf.62b337bc47dbf6fbf5a34e18a361de97.jpg', 0.25, 'keremberke/yolov5m-football'], ['test_images/55219_jpg.rf.cdfe02a50951cf1ad449e940fbb646ac.jpg', 0.25, 'keremberke/yolov5m-football']]
|
16 |
|
17 |
-
|
18 |
-
def predict(image, threshold=0.25, model_id=None):
|
19 |
# update model if required
|
20 |
global current_model_id
|
21 |
global model
|
@@ -36,7 +36,6 @@ def predict(image, threshold=0.25, model_id=None):
|
|
36 |
output_image = Image.fromarray(numpy_image)
|
37 |
return output_image
|
38 |
|
39 |
-
|
40 |
gr.Interface(
|
41 |
title=app_title,
|
42 |
description="Created by 'keremberke'",
|
@@ -44,8 +43,7 @@ gr.Interface(
|
|
44 |
fn=predict,
|
45 |
inputs=[
|
46 |
gr.Image(type="pil"),
|
47 |
-
gr.Slider(maximum=1, step=0.01, value=0.25)
|
48 |
-
gr.Dropdown(models_ids, value=models_ids[-1]),
|
49 |
],
|
50 |
outputs=gr.Image(type="pil"),
|
51 |
examples=examples,
|
|
|
|
|
1 |
import json
|
2 |
import gradio as gr
|
3 |
import yolov5
|
|
|
8 |
models_ids = ['keremberke/yolov5n-football', 'keremberke/yolov5s-football', 'keremberke/yolov5m-football']
|
9 |
article = f"<p style='text-align: center'> <a href='https://huggingface.co/{models_ids[-1]}'>huggingface.co/{models_ids[-1]}</a> | <a href='https://huggingface.co/keremberke/football-object-detection'>huggingface.co/keremberke/football-object-detection</a> | <a href='https://github.com/keremberke/awesome-yolov5-models'>awesome-yolov5-models</a> </p>"
|
10 |
|
11 |
+
# Set default model_id here
|
12 |
+
default_model_id = models_ids[-1]
|
13 |
+
current_model_id = default_model_id
|
14 |
model = yolov5.load(current_model_id)
|
15 |
|
16 |
examples = [['test_images/18_pp_jpg.rf.912a54e24d38371daf61114b9a6b18be.jpg', 0.25, 'keremberke/yolov5m-football'], ['test_images/54881_jpg.rf.62b337bc47dbf6fbf5a34e18a361de97.jpg', 0.25, 'keremberke/yolov5m-football'], ['test_images/55219_jpg.rf.cdfe02a50951cf1ad449e940fbb646ac.jpg', 0.25, 'keremberke/yolov5m-football']]
|
17 |
|
18 |
+
def predict(image, threshold=0.25, model_id=default_model_id):
|
|
|
19 |
# update model if required
|
20 |
global current_model_id
|
21 |
global model
|
|
|
36 |
output_image = Image.fromarray(numpy_image)
|
37 |
return output_image
|
38 |
|
|
|
39 |
gr.Interface(
|
40 |
title=app_title,
|
41 |
description="Created by 'keremberke'",
|
|
|
43 |
fn=predict,
|
44 |
inputs=[
|
45 |
gr.Image(type="pil"),
|
46 |
+
gr.Slider(maximum=1, step=0.01, value=0.25)
|
|
|
47 |
],
|
48 |
outputs=gr.Image(type="pil"),
|
49 |
examples=examples,
|