Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -200,24 +200,35 @@
|
|
200 |
# iface = gr.Interface(fn=inference, inputs="webcam", outputs="image")
|
201 |
# iface.launch()
|
202 |
|
|
|
203 |
import cv2
|
204 |
from ultralytics import YOLO
|
205 |
|
206 |
model = YOLO('Model_IV.pt')
|
207 |
print(model.names)
|
208 |
-
webcamera = cv2.VideoCapture(0)
|
209 |
# webcamera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
|
210 |
# webcamera.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
|
211 |
|
212 |
-
while True:
|
213 |
-
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
|
219 |
-
|
220 |
-
|
221 |
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
# iface = gr.Interface(fn=inference, inputs="webcam", outputs="image")
|
201 |
# iface.launch()
|
202 |
|
203 |
+
import gradio as gr
|
204 |
import cv2
|
205 |
from ultralytics import YOLO
|
206 |
|
207 |
model = YOLO('Model_IV.pt')
|
208 |
print(model.names)
|
209 |
+
# webcamera = cv2.VideoCapture(0)
|
210 |
# webcamera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
|
211 |
# webcamera.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
|
212 |
|
213 |
+
# while True:
|
214 |
+
# success, frame = webcamera.read()
|
215 |
|
216 |
+
# results = model.track(frame, conf=0.2, imgsz=480)
|
217 |
+
# cv2.putText(frame, f"Total: {len(results[0].boxes)}", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
|
218 |
+
# cv2.imshow("Live Camera", results[0].plot())
|
219 |
|
220 |
+
# if cv2.waitKey(1) == ord('q'):
|
221 |
+
# break
|
222 |
|
223 |
+
def run_model(img):
|
224 |
+
results = model(img)
|
225 |
+
annotated_img = results.render()[0]
|
226 |
+
return annotated_img
|
227 |
+
|
228 |
+
# webcamera.release()
|
229 |
+
# cv2.destroyAllWindows()
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
iface = gr.Interface(fn=run_model, inputs="webcam", outputs=annotated_img)
|
234 |
+
iface.launch()
|