Spaces:
Runtime error
Runtime error
michaelwja
commited on
Commit
•
e101990
1
Parent(s):
77d8882
Update app.py
Browse files
app.py
CHANGED
@@ -1,60 +1,39 @@
|
|
1 |
-
import gradio as gr
|
2 |
import torch
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
)
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
""
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
gr.inputs.Dropdown(
|
38 |
-
choices=[
|
39 |
-
"skin_burn.pt",
|
40 |
-
"Other"
|
41 |
-
],
|
42 |
-
default="skin_burn",
|
43 |
-
label="Model",
|
44 |
-
),
|
45 |
-
gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
|
46 |
-
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
|
47 |
-
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
|
48 |
-
]
|
49 |
-
|
50 |
-
outputs = gr.outputs.Image(type="filepath", label="Output Image")
|
51 |
-
title = "Yolov7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors"
|
52 |
-
|
53 |
-
demo_app = gr.Interface(
|
54 |
-
fn=yolov7_inference,
|
55 |
-
inputs=inputs,
|
56 |
outputs=outputs,
|
57 |
-
title=
|
58 |
-
|
59 |
-
)
|
60 |
-
demo_app.launch(debug=True, enable_queue=True)
|
|
|
|
|
1 |
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
+
from PIL import Image
|
5 |
+
|
6 |
+
REPO_ID = "Michael/YOLOv7"
|
7 |
+
FILENAME = "skin_burn.pt"
|
8 |
+
|
9 |
+
|
10 |
+
yolov7_custom_weights = hf_hub_download(repo_id=REPO_ID, filename=FILENAME,repo_type='space')
|
11 |
+
|
12 |
+
model = torch.hub.load('WongKinYiu/yolov7:main',model='custom', path_or_model=yolov7_custom_weights, force_reload=True)
|
13 |
+
def object_detection(im, size=416):
|
14 |
+
results = model(im)
|
15 |
+
results.render()
|
16 |
+
return Image.fromarray(results.imgs[0])
|
17 |
+
|
18 |
+
title = "Yolov7 Custom"
|
19 |
+
|
20 |
+
image = gr.inputs.Image(shape=(614,614), image_mode="RGB", source="upload", label="Upload Image", optional=False)
|
21 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
22 |
+
|
23 |
+
Custom_description="Custom Training Performed on colab style='text-decoration: underline' target='_blank'>Link</a> </center><br> <center>Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors </center> <br> <b>1st</b> class is for Person Detected<br><b>2nd</b> class is for Car Detected"
|
24 |
+
|
25 |
+
Footer = (
|
26 |
+
"MOdel train on our custome dataset")
|
27 |
+
|
28 |
+
|
29 |
+
Top_Title="<center>Yolov7 🚀 Custom Trained style='text-decoration: underline' target='_blank'></center></a>Face with mask and face without mask Detection"
|
30 |
+
css = ".output-image, .input-image {height: 50rem !important; width: 100% !important;}"
|
31 |
+
css = ".image-preview {height: auto !important;}"
|
32 |
+
|
33 |
+
gr.Interface(
|
34 |
+
fn=object_detection,
|
35 |
+
inputs=image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
outputs=outputs,
|
37 |
+
title=Top_Title,
|
38 |
+
description=Custom_description,
|
39 |
+
article=Footer,).launch()
|
|