From 018d0c21c8db4a19a9c54e7257e5a1f11610b53b Mon Sep 17 00:00:00 2001 From: ashok Date: Wed, 2 Apr 2025 08:47:55 -0400 Subject: [PATCH] cleanup --- object_detection/yolo5saveobjects.py | 6 +++--- object_detection/yolo5showobjects.py | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/object_detection/yolo5saveobjects.py b/object_detection/yolo5saveobjects.py index 753526d..9dd2c43 100755 --- a/object_detection/yolo5saveobjects.py +++ b/object_detection/yolo5saveobjects.py @@ -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) diff --git a/object_detection/yolo5showobjects.py b/object_detection/yolo5showobjects.py index af383d3..2787488 100755 --- a/object_detection/yolo5showobjects.py +++ b/object_detection/yolo5showobjects.py @@ -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)