glenn-jocher
commited on
Commit
•
e77c77f
1
Parent(s):
135ec5c
Add check_requirements() (#1853)
Browse files* Add check_requirements()
* add import
* parameterize filename
* add to detect, test
detect.py
CHANGED
@@ -9,8 +9,8 @@ from numpy import random
|
|
9 |
|
10 |
from models.experimental import attempt_load
|
11 |
from utils.datasets import LoadStreams, LoadImages
|
12 |
-
from utils.general import check_img_size, non_max_suppression, apply_classifier, scale_coords,
|
13 |
-
strip_optimizer, set_logging, increment_path
|
14 |
from utils.plots import plot_one_box
|
15 |
from utils.torch_utils import select_device, load_classifier, time_synchronized
|
16 |
|
@@ -162,6 +162,7 @@ if __name__ == '__main__':
|
|
162 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
163 |
opt = parser.parse_args()
|
164 |
print(opt)
|
|
|
165 |
|
166 |
with torch.no_grad():
|
167 |
if opt.update: # update all models (to fix SourceChangeWarning)
|
|
|
9 |
|
10 |
from models.experimental import attempt_load
|
11 |
from utils.datasets import LoadStreams, LoadImages
|
12 |
+
from utils.general import check_img_size, check_requirements, non_max_suppression, apply_classifier, scale_coords, \
|
13 |
+
xyxy2xywh, strip_optimizer, set_logging, increment_path
|
14 |
from utils.plots import plot_one_box
|
15 |
from utils.torch_utils import select_device, load_classifier, time_synchronized
|
16 |
|
|
|
162 |
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
163 |
opt = parser.parse_args()
|
164 |
print(opt)
|
165 |
+
check_requirements()
|
166 |
|
167 |
with torch.no_grad():
|
168 |
if opt.update: # update all models (to fix SourceChangeWarning)
|
test.py
CHANGED
@@ -11,8 +11,8 @@ from tqdm import tqdm
|
|
11 |
|
12 |
from models.experimental import attempt_load
|
13 |
from utils.datasets import create_dataloader
|
14 |
-
from utils.general import coco80_to_coco91_class, check_dataset, check_file, check_img_size,
|
15 |
-
non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path
|
16 |
from utils.loss import compute_loss
|
17 |
from utils.metrics import ap_per_class, ConfusionMatrix
|
18 |
from utils.plots import plot_images, output_to_target, plot_study_txt
|
@@ -302,6 +302,7 @@ if __name__ == '__main__':
|
|
302 |
opt.save_json |= opt.data.endswith('coco.yaml')
|
303 |
opt.data = check_file(opt.data) # check file
|
304 |
print(opt)
|
|
|
305 |
|
306 |
if opt.task in ['val', 'test']: # run normally
|
307 |
test(opt.data,
|
|
|
11 |
|
12 |
from models.experimental import attempt_load
|
13 |
from utils.datasets import create_dataloader
|
14 |
+
from utils.general import coco80_to_coco91_class, check_dataset, check_file, check_img_size, check_requirements, \
|
15 |
+
box_iou, non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path
|
16 |
from utils.loss import compute_loss
|
17 |
from utils.metrics import ap_per_class, ConfusionMatrix
|
18 |
from utils.plots import plot_images, output_to_target, plot_study_txt
|
|
|
302 |
opt.save_json |= opt.data.endswith('coco.yaml')
|
303 |
opt.data = check_file(opt.data) # check file
|
304 |
print(opt)
|
305 |
+
check_requirements()
|
306 |
|
307 |
if opt.task in ['val', 'test']: # run normally
|
308 |
test(opt.data,
|
train.py
CHANGED
@@ -28,7 +28,7 @@ from utils.autoanchor import check_anchors
|
|
28 |
from utils.datasets import create_dataloader
|
29 |
from utils.general import labels_to_class_weights, increment_path, labels_to_image_weights, init_seeds, \
|
30 |
fitness, strip_optimizer, get_latest_run, check_dataset, check_file, check_git_status, check_img_size, \
|
31 |
-
print_mutation, set_logging, one_cycle
|
32 |
from utils.google_utils import attempt_download
|
33 |
from utils.loss import compute_loss
|
34 |
from utils.plots import plot_images, plot_labels, plot_results, plot_evolution
|
@@ -472,6 +472,7 @@ if __name__ == '__main__':
|
|
472 |
set_logging(opt.global_rank)
|
473 |
if opt.global_rank in [-1, 0]:
|
474 |
check_git_status()
|
|
|
475 |
|
476 |
# Resume
|
477 |
if opt.resume: # resume an interrupted run
|
|
|
28 |
from utils.datasets import create_dataloader
|
29 |
from utils.general import labels_to_class_weights, increment_path, labels_to_image_weights, init_seeds, \
|
30 |
fitness, strip_optimizer, get_latest_run, check_dataset, check_file, check_git_status, check_img_size, \
|
31 |
+
check_requirements, print_mutation, set_logging, one_cycle
|
32 |
from utils.google_utils import attempt_download
|
33 |
from utils.loss import compute_loss
|
34 |
from utils.plots import plot_images, plot_labels, plot_results, plot_evolution
|
|
|
472 |
set_logging(opt.global_rank)
|
473 |
if opt.global_rank in [-1, 0]:
|
474 |
check_git_status()
|
475 |
+
check_requirements()
|
476 |
|
477 |
# Resume
|
478 |
if opt.resume: # resume an interrupted run
|
utils/general.py
CHANGED
@@ -53,6 +53,14 @@ def check_git_status():
|
|
53 |
print(s[s.find('Your branch is behind'):s.find('\n\n')] + '\n')
|
54 |
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
def check_img_size(img_size, s=32):
|
57 |
# Verify img_size is a multiple of stride s
|
58 |
new_size = make_divisible(img_size, int(s)) # ceil gs-multiple
|
|
|
53 |
print(s[s.find('Your branch is behind'):s.find('\n\n')] + '\n')
|
54 |
|
55 |
|
56 |
+
def check_requirements(file='requirements.txt'):
|
57 |
+
# Check installed dependencies meet requirements
|
58 |
+
import pkg_resources
|
59 |
+
requirements = pkg_resources.parse_requirements(Path(file).open())
|
60 |
+
requirements = [x.name + ''.join(*x.specs) if len(x.specs) else x.name for x in requirements]
|
61 |
+
pkg_resources.require(requirements) # DistributionNotFound or VersionConflict exception if requirements not met
|
62 |
+
|
63 |
+
|
64 |
def check_img_size(img_size, s=32):
|
65 |
# Verify img_size is a multiple of stride s
|
66 |
new_size = make_divisible(img_size, int(s)) # ceil gs-multiple
|