Commit
·
eb6db42
1
Parent(s):
c402a93
Added Yolov5
Browse files
run.py
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
|
2 |
import gradio as gr
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
return [
|
7 |
-
|
8 |
|
9 |
demo = gr.Interface(
|
10 |
-
|
11 |
-
[gr.Image(source="webcam", tool=None)
|
12 |
-
["image"
|
13 |
)
|
14 |
-
|
15 |
if __name__ == "__main__":
|
16 |
demo.launch()
|
|
|
1 |
|
2 |
import gradio as gr
|
3 |
+
import numpy as np
|
4 |
+
import torch
|
5 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path='last2.pt', force_reload=True)
|
6 |
|
7 |
+
def detect(im):
|
8 |
+
results = model(im)
|
9 |
+
return [np.squeeze(results.render())]
|
10 |
+
#return [im]
|
11 |
|
12 |
demo = gr.Interface(
|
13 |
+
detect,
|
14 |
+
[gr.Image(source="webcam", tool=None)],
|
15 |
+
["image"],
|
16 |
)
|
|
|
17 |
if __name__ == "__main__":
|
18 |
demo.launch()
|