Slightly modify CLI execution (#3687)
* Slightly modify CLI execution This simple change makes it easier to run the primary functions of this repo (train/detect/test) from within Python. An object which represents `opt` can be constructed and fed to the `main` function of each of these modules, rather than having to call the lower level functions directly, or run the module as a script. * Update export.py Add CLI parsing update for more convenient module usage within Python. Co-authored-by: Lewis Belcher <lb@desupervised.io>
This commit is contained in:
1 parent
bf209f6fe9
commit
bfb2276b1d
4 files changed
+41
-6
No files matched your search
@@ -172,7 +172,7 @@ def detect(weights='yolov5s.pt', # model.pt path(s)
|
||||
print(f'Done. ({time.time() - t0:.3f}s)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def parse_opt():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pt', help='model.pt path(s)')
|
||||
parser.add_argument('--source', type=str, default='data/images', help='file/dir/URL/glob, 0 for webcam')
|
||||
@@ -198,7 +198,15 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
|
||||
parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')
|
||||
opt = parser.parse_args()
|
||||
return opt
|
||||
|
||||
|
||||
def main(opt):
|
||||
print(opt)
|
||||
check_requirements(exclude=('tensorboard', 'thop'))
|
||||
|
||||
detect(**vars(opt))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
opt = parse_opt()
|
||||
main(opt)
|
||||
Reference in new issue
Block a user