Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,14 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
import os
|
3 |
-
import
|
4 |
import torch.backends.cudnn as cudnn
|
5 |
from models.experimental import attempt_load
|
6 |
-
|
7 |
from utils.datasets import LoadStreams, LoadImages
|
8 |
from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier,scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path
|
9 |
from utils.plots import plot_one_box
|
@@ -12,10 +17,10 @@ from utils.torch_utils import select_device, load_classifier, time_synchronized,
|
|
12 |
os.system('git clone https://github.com/WongKinYiu/yolov7')
|
13 |
|
14 |
|
15 |
-
def detect(inp):
|
16 |
os.system('python ./yolov7/detect.py --weights best.pt --conf 0.25 --img-size 640 --source f{inp} --project ./yolov7/runs/detect ')
|
17 |
otp=inp.split('/')[2]
|
18 |
-
return f"./yolov7/runs/detect/exp/*"
|
19 |
|
20 |
|
21 |
|
@@ -53,10 +58,8 @@ def Custom_detect(img,model):
|
|
53 |
img.save("Temp_file/test.jpg")
|
54 |
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, opt.trace
|
55 |
save_img = True
|
56 |
-
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|
57 |
-
|
58 |
-
save_dir = Path(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok))
|
59 |
-
(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True)
|
60 |
set_logging()
|
61 |
device = select_device(opt.device)
|
62 |
half = device.type != 'cpu'
|
|
|
1 |
+
import torch
|
2 |
+
import argparse
|
3 |
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
+
from numpy import random
|
6 |
+
from pathlib import Path
|
7 |
import os
|
8 |
+
import time
|
9 |
import torch.backends.cudnn as cudnn
|
10 |
from models.experimental import attempt_load
|
11 |
+
import cv2
|
12 |
from utils.datasets import LoadStreams, LoadImages
|
13 |
from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier,scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path
|
14 |
from utils.plots import plot_one_box
|
|
|
17 |
os.system('git clone https://github.com/WongKinYiu/yolov7')
|
18 |
|
19 |
|
20 |
+
'''def detect(inp):
|
21 |
os.system('python ./yolov7/detect.py --weights best.pt --conf 0.25 --img-size 640 --source f{inp} --project ./yolov7/runs/detect ')
|
22 |
otp=inp.split('/')[2]
|
23 |
+
return f"./yolov7/runs/detect/exp/*"'''
|
24 |
|
25 |
|
26 |
|
|
|
58 |
img.save("Temp_file/test.jpg")
|
59 |
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, opt.trace
|
60 |
save_img = True
|
61 |
+
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://'))
|
62 |
+
save_dir = Path(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok))(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True)
|
|
|
|
|
63 |
set_logging()
|
64 |
device = select_device(opt.device)
|
65 |
half = device.type != 'cpu'
|