Spaces:
Running
Running
changed app
Browse files- .gitignore +0 -1
- app.py +5 -18
- img/test-image-2.jpg +0 -0
- img/test-image.jpg +0 -0
.gitignore
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
flagged/
|
2 |
*.pt
|
3 |
*.png
|
4 |
-
*.jpg
|
5 |
gradio_cached_examples/
|
|
|
1 |
flagged/
|
2 |
*.pt
|
3 |
*.png
|
|
|
4 |
gradio_cached_examples/
|
app.py
CHANGED
@@ -6,27 +6,12 @@ import os
|
|
6 |
import torch
|
7 |
import ultralytics
|
8 |
|
9 |
-
file_urls = [
|
10 |
-
'https://www.dropbox.com/s/bc9r8n7919cbc77/test-image.jpg?dl=0',
|
11 |
-
'https://www.dropbox.com/s/fkmzgdm6okdzxdk/test-image-2.jpg?dl=0',
|
12 |
-
]
|
13 |
-
|
14 |
-
def download_file(url, save_name):
|
15 |
-
url = url
|
16 |
-
if not os.path.exists(save_name):
|
17 |
-
file = requests.get(url)
|
18 |
-
open(save_name, 'wb').write(file.content)
|
19 |
-
|
20 |
-
for i, url in enumerate(file_urls):
|
21 |
-
download_file(
|
22 |
-
file_urls[i],
|
23 |
-
f"image_{i}.jpg"
|
24 |
-
)
|
25 |
|
26 |
model = torch.hub.load("ultralytics/yolov5", "custom", path="yolov5_0.65map_exp7_best.pt",
|
27 |
force_reload=False)
|
|
|
28 |
|
29 |
-
path = [['
|
30 |
|
31 |
def show_preds_image(image_path):
|
32 |
image = cv2.imread(image_path)
|
@@ -42,7 +27,9 @@ def show_preds_image(image_path):
|
|
42 |
lineType=cv2.LINE_AA
|
43 |
)
|
44 |
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
45 |
-
|
|
|
|
|
46 |
inputs_image = [
|
47 |
gr.components.Image(type="filepath", label="Input Image"),
|
48 |
]
|
|
|
6 |
import torch
|
7 |
import ultralytics
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
model = torch.hub.load("ultralytics/yolov5", "custom", path="yolov5_0.65map_exp7_best.pt",
|
11 |
force_reload=False)
|
12 |
+
model.conf = 0.20 # NMS confidence threshold
|
13 |
|
14 |
+
path = [['img/test-image.jpg'], ['img/test-image-2']]
|
15 |
|
16 |
def show_preds_image(image_path):
|
17 |
image = cv2.imread(image_path)
|
|
|
27 |
lineType=cv2.LINE_AA
|
28 |
)
|
29 |
return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
inputs_image = [
|
34 |
gr.components.Image(type="filepath", label="Input Image"),
|
35 |
]
|
img/test-image-2.jpg
ADDED
img/test-image.jpg
ADDED