Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,14 +6,14 @@ import gradio as gr
|
|
| 6 |
|
| 7 |
def fonk(video_path):
|
| 8 |
|
| 9 |
-
model=YOLO("best.pt")
|
| 10 |
-
cap=cv2.VideoCapture(video_path)
|
| 11 |
|
| 12 |
frame_width = int(cap.get(3))
|
| 13 |
frame_height = int(cap.get(4))
|
| 14 |
size = (frame_width, frame_height)
|
| 15 |
-
|
| 16 |
-
cv2.VideoWriter_fourcc(
|
| 17 |
10, size)
|
| 18 |
|
| 19 |
|
|
@@ -30,14 +30,14 @@ def fonk(video_path):
|
|
| 30 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
| 31 |
print(x1, y1, x2, y2)
|
| 32 |
frame= cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
| 33 |
-
output_video.write(frame)
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
demo = gr.Interface(fonk,
|
| 38 |
inputs= gr.Video(),
|
| 39 |
outputs=gr.Video(),
|
| 40 |
-
examples=["cow-video-cows-mooing-and-grazing-in-a-field.mp4"],
|
| 41 |
title= "cows",
|
| 42 |
cache_examples=True)
|
| 43 |
demo.launch()
|
|
|
|
| 6 |
|
| 7 |
def fonk(video_path):
|
| 8 |
|
| 9 |
+
model=YOLO("/home/kahraman/Masaüstü/HuggingFace_Models_and_Spaces/Cattle_Detection_with_YOLOV8/best.pt")
|
| 10 |
+
cap=cv2.VideoCapture(video_path)
|
| 11 |
|
| 12 |
frame_width = int(cap.get(3))
|
| 13 |
frame_height = int(cap.get(4))
|
| 14 |
size = (frame_width, frame_height)
|
| 15 |
+
writer = cv2.VideoWriter("filename.mp4",
|
| 16 |
+
cv2.VideoWriter_fourcc(*"DIVX"),
|
| 17 |
10, size)
|
| 18 |
|
| 19 |
|
|
|
|
| 30 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
| 31 |
print(x1, y1, x2, y2)
|
| 32 |
frame= cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
| 33 |
+
output_video= writer.write(frame)
|
| 34 |
|
| 35 |
+
return output_video
|
| 36 |
|
| 37 |
demo = gr.Interface(fonk,
|
| 38 |
inputs= gr.Video(),
|
| 39 |
outputs=gr.Video(),
|
| 40 |
+
examples=["/home/kahraman/Masaüstü/HuggingFace_Models_and_Spaces/Cattle_Detection_with_YOLOV8/cow-video-cows-mooing-and-grazing-in-a-field.mp4"],
|
| 41 |
title= "cows",
|
| 42 |
cache_examples=True)
|
| 43 |
demo.launch()
|