Spaces:
Runtime error
Runtime error
Commit ·
062d935
1
Parent(s): c9149a7
Update detect.py
Browse files
detect.py
CHANGED
|
@@ -15,35 +15,7 @@ from utils.plots import plot_one_box
|
|
| 15 |
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
| 16 |
|
| 17 |
|
| 18 |
-
def detect(save_img=False):
|
| 19 |
-
parser = argparse.ArgumentParser()
|
| 20 |
-
parser.add_argument('--weights', nargs='+', type=str, default='yolov7.pt', help='model.pt path(s)')
|
| 21 |
-
parser.add_argument('--source', type=str, default='inference/images', help='source') # file/folder, 0 for webcam
|
| 22 |
-
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
| 23 |
-
parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
|
| 24 |
-
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
|
| 25 |
-
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 26 |
-
parser.add_argument('--view-img', action='store_true', help='display results')
|
| 27 |
-
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
|
| 28 |
-
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
|
| 29 |
-
parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
|
| 30 |
-
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
|
| 31 |
-
parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
|
| 32 |
-
parser.add_argument('--augment', action='store_true', help='augmented inference')
|
| 33 |
-
parser.add_argument('--update', action='store_true', help='update all models')
|
| 34 |
-
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
| 35 |
-
parser.add_argument('--name', default='exp', help='save results to project/name')
|
| 36 |
-
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
| 37 |
-
parser.add_argument('--no-trace', action='store_true', help='don`t trace model')
|
| 38 |
-
opt = parser.parse_args()
|
| 39 |
-
print(opt)
|
| 40 |
-
|
| 41 |
-
np.random.seed(opt.seed)
|
| 42 |
-
|
| 43 |
-
sort_tracker = Sort(max_age=5,
|
| 44 |
-
min_hits=2,
|
| 45 |
-
iou_threshold=0.2)
|
| 46 |
-
|
| 47 |
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, not opt.no_trace
|
| 48 |
save_img = not opt.nosave and not source.endswith('.txt') # save inference images
|
| 49 |
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|
|
|
|
| 15 |
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
| 16 |
|
| 17 |
|
| 18 |
+
def detect(save_img=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, not opt.no_trace
|
| 20 |
save_img = not opt.nosave and not source.endswith('.txt') # save inference images
|
| 21 |
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|