jbprincipe1 commited on
Commit
0f5dc06
·
verified ·
1 Parent(s): 72c970f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import gradio as gr
3
+ from ultralytics import YOLO
4
+
5
+ # Load YOLOv8-Pose model (downloads if not cached)
6
+ model = YOLO("yolov8s-pose.pt") # You can also use yolov8s/m/l/x-pose.pt
7
+
8
+ def predict_pose(frame):
9
+ # Run YOLOv8-Pose inference
10
+ results = model.predict(frame, imgsz=640, conf=0.5)[0]
11
+
12
+ # Draw results on frame
13
+ annotated_frame = results.plot() # YOLOv8 handles drawing
14
+ return annotated_frame
15
+
16
+ # Set up Gradio interface
17
+ with gr.Blocks() as demo:
18
+ with gr.Row():
19
+ with gr.Column():
20
+ input_img = gr.Image(sources=["webcam"])
21
+ with gr.Column():
22
+ output_img = gr.Image(streaming=True)
23
+ input_img.stream(predict_pose, input_img, output_img,
24
+ time_limit=30, stream_every=0.1, concurrency_limit=30)
25
+
26
+ demo.launch()