Spaces:
Build error
Build error
owaiskha9654
commited on
Commit
·
3fdb999
1
Parent(s):
51ecb43
Update app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,8 @@ from utils.general import check_img_size, check_requirements, check_imshow, non_
|
|
16 |
from utils.plots import plot_one_box
|
17 |
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
18 |
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt")
|
19 |
-
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e.pt")
|
20 |
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt")
|
21 |
|
22 |
-
|
23 |
def detect_Custom(img,model):
|
24 |
if model =='Yolo_v7_Custom_trained_By_Owais':
|
25 |
model='best' # Naming Convention for yolov7 See output file of https://www.kaggle.com/code/owaiskhan9654/training-yolov7-on-kaggle-on-custom-dataset/data
|
@@ -63,7 +61,7 @@ def detect_Custom(img,model):
|
|
63 |
|
64 |
classify = False
|
65 |
if classify:
|
66 |
-
modelc = load_classifier(name='resnet101', n=2)
|
67 |
modelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['model']).to(device).eval()
|
68 |
vid_path, vid_writer = None, None
|
69 |
if webcam:
|
@@ -93,7 +91,6 @@ def detect_Custom(img,model):
|
|
93 |
t2 = time_synchronized()
|
94 |
|
95 |
|
96 |
-
# Apply Classifier
|
97 |
if classify:
|
98 |
pred = apply_classifier(pred, modelc, img, im0s)
|
99 |
|
@@ -172,6 +169,6 @@ Footer = (
|
|
172 |
|
173 |
examples1=[["Image1.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image2.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image3.jpeg", "Yolo_v7_Custom_trained_By_Owais",],["Image4.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image5.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image6.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["horses.jpeg", "yolov7"],["horses.jpeg", "yolov7-e6"]]
|
174 |
|
175 |
-
Top_Title="<center>Yolov7 🚀 Custom Trained by <a href='https://www.linkedin.com/in/owaiskhan9654/' style='text-decoration: underline' target='_blank'>Owais Ahmad </center></a>🚗Car and 👦Person Detection"
|
176 |
|
177 |
gr.Interface(detect_Custom,[gr.Image(type="pil"),gr.Dropdown(default="Yolo_v7_Custom_trained_By_Owais",choices=["Yolo_v7_Custom_trained_By_Owais","yolov7","yolov7-e6"])],gr.Image(type="pil"),title=Top_Title,examples=examples1,description=Custom_description,article=Footer,cache_examples=False).launch()
|
|
|
16 |
from utils.plots import plot_one_box
|
17 |
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
18 |
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt")
|
|
|
19 |
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt")
|
20 |
|
|
|
21 |
def detect_Custom(img,model):
|
22 |
if model =='Yolo_v7_Custom_trained_By_Owais':
|
23 |
model='best' # Naming Convention for yolov7 See output file of https://www.kaggle.com/code/owaiskhan9654/training-yolov7-on-kaggle-on-custom-dataset/data
|
|
|
61 |
|
62 |
classify = False
|
63 |
if classify:
|
64 |
+
modelc = load_classifier(name='resnet101', n=2)
|
65 |
modelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['model']).to(device).eval()
|
66 |
vid_path, vid_writer = None, None
|
67 |
if webcam:
|
|
|
91 |
t2 = time_synchronized()
|
92 |
|
93 |
|
|
|
94 |
if classify:
|
95 |
pred = apply_classifier(pred, modelc, img, im0s)
|
96 |
|
|
|
169 |
|
170 |
examples1=[["Image1.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image2.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image3.jpeg", "Yolo_v7_Custom_trained_By_Owais",],["Image4.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image5.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image6.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["horses.jpeg", "yolov7"],["horses.jpeg", "yolov7-e6"]]
|
171 |
|
172 |
+
Top_Title="<center>Yolov7 🚀 Custom Trained by <a href='https://www.linkedin.com/in/owaiskhan9654/' style='text-decoration: underline' target='_blank'>Owais Ahmad </center></a>🚗Car and 👦Person Detection Class"
|
173 |
|
174 |
gr.Interface(detect_Custom,[gr.Image(type="pil"),gr.Dropdown(default="Yolo_v7_Custom_trained_By_Owais",choices=["Yolo_v7_Custom_trained_By_Owais","yolov7","yolov7-e6"])],gr.Image(type="pil"),title=Top_Title,examples=examples1,description=Custom_description,article=Footer,cache_examples=False).launch()
|