update
Browse files- app.py +10 -6
- infer.py +8 -4
- requirements.txt +5 -3
app.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
import numpy as np
|
2 |
-
|
3 |
import gradio as gr
|
4 |
from infer import detections
|
5 |
-
|
6 |
-
'''
|
7 |
-
'''
|
8 |
import os
|
9 |
os.system("mkdir data")
|
10 |
os.system("mkdir data/models")
|
11 |
os.system("wget https://www.cs.cmu.edu/~walt/models/walt_people.pth -O data/models/walt_people.pth")
|
12 |
os.system("wget https://www.cs.cmu.edu/~walt/models/walt_vehicle.pth -O data/models/walt_vehicle.pth")
|
|
|
|
|
13 |
def walt_demo(input_img):
|
14 |
#detect_people = detections('configs/walt/walt_people.py', 'cuda:0', model_path='data/models/walt_people.pth')
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
count = 0
|
17 |
#img = detect_people.run_on_image(input_img)
|
18 |
output_img = detect.run_on_image(input_img)
|
@@ -42,7 +47,6 @@ article="""
|
|
42 |
examples = [
|
43 |
'demo/images/img_1.jpg',
|
44 |
'demo/images/img_2.jpg',
|
45 |
-
'demo/images/img_3.png',
|
46 |
'demo/images/img_4.png',
|
47 |
]
|
48 |
|
|
|
1 |
import numpy as np
|
2 |
+
import torch
|
3 |
import gradio as gr
|
4 |
from infer import detections
|
|
|
|
|
|
|
5 |
import os
|
6 |
os.system("mkdir data")
|
7 |
os.system("mkdir data/models")
|
8 |
os.system("wget https://www.cs.cmu.edu/~walt/models/walt_people.pth -O data/models/walt_people.pth")
|
9 |
os.system("wget https://www.cs.cmu.edu/~walt/models/walt_vehicle.pth -O data/models/walt_vehicle.pth")
|
10 |
+
'''
|
11 |
+
'''
|
12 |
def walt_demo(input_img):
|
13 |
#detect_people = detections('configs/walt/walt_people.py', 'cuda:0', model_path='data/models/walt_people.pth')
|
14 |
+
if torch.cuda.is_available() == False:
|
15 |
+
device='cpu'
|
16 |
+
else:
|
17 |
+
device='cuda:0'
|
18 |
+
#detect_people = detections('configs/walt/walt_people.py', device, model_path='data/models/walt_people.pth')
|
19 |
+
detect = detections('configs/walt/walt_vehicle.py', device, model_path='data/models/walt_vehicle.pth', threshold=0.75)
|
20 |
+
|
21 |
count = 0
|
22 |
#img = detect_people.run_on_image(input_img)
|
23 |
output_img = detect.run_on_image(input_img)
|
|
|
47 |
examples = [
|
48 |
'demo/images/img_1.jpg',
|
49 |
'demo/images/img_2.jpg',
|
|
|
50 |
'demo/images/img_4.png',
|
51 |
]
|
52 |
|
infer.py
CHANGED
@@ -11,12 +11,12 @@ import os
|
|
11 |
import cv2, glob
|
12 |
|
13 |
class detections():
|
14 |
-
def __init__(self, cfg_path, device, model_path = 'data/models/walt_vehicle.pth'):
|
15 |
self.model = init_detector(cfg_path, model_path, device=device)
|
16 |
self.all_preds = []
|
17 |
self.all_scores = []
|
18 |
self.index = []
|
19 |
-
self.score_thr =
|
20 |
self.result = []
|
21 |
self.record_dict = {'model': cfg_path,'results': []}
|
22 |
self.detect_count = []
|
@@ -75,8 +75,12 @@ class detections():
|
|
75 |
|
76 |
|
77 |
def main():
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
filenames = sorted(glob.glob('demo/images/*'))
|
81 |
count = 0
|
82 |
for filename in filenames:
|
|
|
11 |
import cv2, glob
|
12 |
|
13 |
class detections():
|
14 |
+
def __init__(self, cfg_path, device, model_path = 'data/models/walt_vehicle.pth', threshold=0.85):
|
15 |
self.model = init_detector(cfg_path, model_path, device=device)
|
16 |
self.all_preds = []
|
17 |
self.all_scores = []
|
18 |
self.index = []
|
19 |
+
self.score_thr = threshold
|
20 |
self.result = []
|
21 |
self.record_dict = {'model': cfg_path,'results': []}
|
22 |
self.detect_count = []
|
|
|
75 |
|
76 |
|
77 |
def main():
|
78 |
+
if torch.cuda.is_available() == False:
|
79 |
+
device='cpu'
|
80 |
+
else:
|
81 |
+
device='cuda:0'
|
82 |
+
detect_people = detections('configs/walt/walt_people.py', device, model_path='data/models/walt_people.pth')
|
83 |
+
detect = detections('configs/walt/walt_vehicle.py', device, model_path='data/models/walt_vehicle.pth')
|
84 |
filenames = sorted(glob.glob('demo/images/*'))
|
85 |
count = 0
|
86 |
for filename in filenames:
|
requirements.txt
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
3 |
gradio==3.0.20
|
4 |
timm
|
5 |
scikit-image
|
6 |
imagesize
|
7 |
-
torchvision==0.10.0
|
8 |
imantics
|
9 |
terminaltables
|
10 |
pycocotools
|
|
|
1 |
+
--find-links https://download.pytorch.org/whl/torch_stable.html
|
2 |
+
torch==1.9.0+cpu
|
3 |
+
--find-links https://download.openmmlab.com/mmcv/dist/cpu/torch1.9.0/index.html
|
4 |
+
mmcv-full==1.4.0
|
5 |
gradio==3.0.20
|
6 |
timm
|
7 |
scikit-image
|
8 |
imagesize
|
9 |
+
torchvision==0.10.0+cpu
|
10 |
imantics
|
11 |
terminaltables
|
12 |
pycocotools
|