yasserrmd commited on
Commit
c3d6a85
·
verified ·
1 Parent(s): df98ef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -50,13 +50,12 @@ def generate_journal_with_images(video_path):
50
  # Make predictions using YOLOv10 on the current frame
51
  results = model.predict(source=frame_rgb, device=device)
52
 
53
- # Loop through the list of results and render bounding boxes
54
- for result in results:
55
- result.render() # Render the results on the image (modifies the frame in-place)
56
 
57
- # Save the image with bounding boxes
58
  frame_filename = os.path.join(output_folder, f"frame_{frame_count}.jpg")
59
- cv2.imwrite(frame_filename, frame_rgb[:, :, ::-1]) # Convert back to BGR for saving
60
  saved_images.append(frame_filename)
61
 
62
  # Extract labels (class indices) and map them to class names
 
50
  # Make predictions using YOLOv10 on the current frame
51
  results = model.predict(source=frame_rgb, device=device)
52
 
53
+ # Plot bounding boxes and labels on the image
54
+ annotated_frame = results[0].plot() # Plot detection results on the frame
 
55
 
56
+ # Save the annotated image
57
  frame_filename = os.path.join(output_folder, f"frame_{frame_count}.jpg")
58
+ cv2.imwrite(frame_filename, annotated_frame[:, :, ::-1]) # Convert back to BGR for saving
59
  saved_images.append(frame_filename)
60
 
61
  # Extract labels (class indices) and map them to class names