cleanup
This commit is contained in:
parent
238f159cab
commit
018d0c21c8
2 changed files with 10 additions and 10 deletions
|
@ -94,7 +94,7 @@ def generate_frames():
|
|||
detections = results.pandas().xyxy[0] # Convert detections to Pandas DataFrame
|
||||
|
||||
if detections.empty:
|
||||
print("🚫 No objects detected.")
|
||||
print("No objects detected.")
|
||||
else:
|
||||
print(f"✅ Detected {len(detections)} objects!")
|
||||
|
||||
|
@ -111,7 +111,7 @@ def generate_frames():
|
|||
cv2.putText(frame, f"{label} ({confidence:.2f})", (x1, y1 - 10),
|
||||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
||||
|
||||
# Encode and yield the frame as JPEG
|
||||
# Encode and present the frame as JPEG
|
||||
_, buffer = cv2.imencode('.jpg', frame)
|
||||
yield (b'--frame\r\n'
|
||||
b'Content-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
|
||||
|
@ -123,6 +123,6 @@ def video_feed():
|
|||
return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("🚀 Server running at http://localhost:5000/video")
|
||||
print("Running at http://localhost:5000/video")
|
||||
app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@ import numpy as np
|
|||
import warnings
|
||||
|
||||
|
||||
warnings.simplefilter("ignore", category=FutureWarning)
|
||||
warnings.simplefilter("ignore", category=FutureWarning) #ignore torch warnings
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
YOUTUBE_URL = "https://www.youtube.com/watch?v=i3w7qZVSAsY" # Stream URL
|
||||
YOUTUBE_URL = "https://www.youtube.com/watch?v=i3w7qZVSAsY" # Stream URL example
|
||||
CONFIDENCE_THRESHOLD = 0.25 # Confidence threshold for object detection
|
||||
MODEL = "yolov5s" # YOLO model version (yolov5s, yolov5m, etc.)
|
||||
|
||||
# Load YOLOv5 model
|
||||
print("🔄 Loading YOLOv5 model...")
|
||||
# Load YOLO5 model
|
||||
print("Loading YOLOv5 model...")
|
||||
model = torch.hub.load("ultralytics/yolov5", "custom", path=MODEL, force_reload=True)
|
||||
print("✅ YOLOv5 loaded successfully!")
|
||||
print("YOLOv5 loaded successfully!")
|
||||
|
||||
def get_stream_url():
|
||||
"""Fetch fresh 720p YouTube stream URL using yt-dlp."""
|
||||
|
@ -57,7 +57,7 @@ def generate_frames():
|
|||
detections = results.pandas().xyxy[0] # Convert detections to Pandas DataFrame
|
||||
|
||||
if detections.empty:
|
||||
print("🚫 No objects detected in this frame.")
|
||||
print("No objects detected in this frame.")
|
||||
else:
|
||||
print(f"✅ Detected {len(detections)} objects!")
|
||||
print(detections[["name", "confidence"]]) # Print detected object names and confidence
|
||||
|
@ -85,6 +85,6 @@ def video_feed():
|
|||
return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("🚀 Server running at http://localhost:5000/video")
|
||||
print("Running at http://localhost:5000/video")
|
||||
app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue