glenn-jocher
commited on
Commit
•
f3e3f76
1
Parent(s):
dbc06ce
TFLite prep (#4436)
Browse files- detect.py +2 -1
- utils/general.py +8 -5
detect.py
CHANGED
@@ -67,7 +67,8 @@ def run(weights='yolov5s.pt', # model.pt path(s)
|
|
67 |
|
68 |
# Load model
|
69 |
w = weights[0] if isinstance(weights, list) else weights
|
70 |
-
classify,
|
|
|
71 |
stride, names = 64, [f'class{i}' for i in range(1000)] # assign defaults
|
72 |
if pt:
|
73 |
model = attempt_load(weights, map_location=device) # load FP32 model
|
|
|
67 |
|
68 |
# Load model
|
69 |
w = weights[0] if isinstance(weights, list) else weights
|
70 |
+
classify, suffix = False, Path(w).suffix.lower()
|
71 |
+
pt, onnx, tflite, pb, graph_def = (suffix == x for x in ['.pt', '.onnx', '.tflite', '.pb', '']) # backend
|
72 |
stride, names = 64, [f'class{i}' for i in range(1000)] # assign defaults
|
73 |
if pt:
|
74 |
model = attempt_load(weights, map_location=device) # load FP32 model
|
utils/general.py
CHANGED
@@ -203,11 +203,14 @@ def check_requirements(requirements='requirements.txt', exclude=()):
|
|
203 |
print(emojis(s))
|
204 |
|
205 |
|
206 |
-
def check_img_size(
|
207 |
-
# Verify
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
211 |
return new_size
|
212 |
|
213 |
|
|
|
203 |
print(emojis(s))
|
204 |
|
205 |
|
206 |
+
def check_img_size(imgsz, s=32, floor=0):
|
207 |
+
# Verify image size is a multiple of stride s in each dimension
|
208 |
+
if isinstance(imgsz, int): # integer i.e. img_size=640
|
209 |
+
new_size = max(make_divisible(imgsz, int(s)), floor)
|
210 |
+
else: # list i.e. img_size=[640, 480]
|
211 |
+
new_size = [max(make_divisible(x, int(s)), floor) for x in imgsz]
|
212 |
+
if new_size != imgsz:
|
213 |
+
print(f'WARNING: --img-size {imgsz} must be multiple of max stride {s}, updating to {new_size}')
|
214 |
return new_size
|
215 |
|
216 |
|