Spaces:
Build error
Build error
owaiskha9654
commited on
Commit
•
bb14fd9
1
Parent(s):
08f90c6
Update app.py
Browse files
app.py
CHANGED
@@ -56,6 +56,11 @@ def detect_Custom(img,model):
|
|
56 |
model = TracedModel(model, device, opt.img_size)
|
57 |
if half:
|
58 |
model.half()
|
|
|
|
|
|
|
|
|
|
|
59 |
vid_path, vid_writer = None, None
|
60 |
if webcam:
|
61 |
view_img = check_imshow()
|
@@ -82,6 +87,11 @@ def detect_Custom(img,model):
|
|
82 |
|
83 |
pred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
|
84 |
t2 = time_synchronized()
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
for i, det in enumerate(pred):
|
87 |
if webcam:
|
@@ -160,4 +170,4 @@ examples1=[["Image1.jpeg", "Yolo_v7_Custom_trained_By_Owais"],["Image2.jpeg", "Y
|
|
160 |
|
161 |
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>"
|
162 |
|
163 |
-
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
|
|
|
56 |
model = TracedModel(model, device, opt.img_size)
|
57 |
if half:
|
58 |
model.half()
|
59 |
+
|
60 |
+
classify = False
|
61 |
+
if classify:
|
62 |
+
modelc = load_classifier(name='resnet101', n=2) # initialize
|
63 |
+
modelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['model']).to(device).eval()
|
64 |
vid_path, vid_writer = None, None
|
65 |
if webcam:
|
66 |
view_img = check_imshow()
|
|
|
87 |
|
88 |
pred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
|
89 |
t2 = time_synchronized()
|
90 |
+
|
91 |
+
|
92 |
+
# Apply Classifier
|
93 |
+
if classify:
|
94 |
+
pred = apply_classifier(pred, modelc, img, im0s)
|
95 |
|
96 |
for i, det in enumerate(pred):
|
97 |
if webcam:
|
|
|
170 |
|
171 |
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>"
|
172 |
|
173 |
+
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).launch()
|