gTTs Attribute error #10286
Replies: 1 comment 3 replies
-
Hello! It looks like you’re encountering an error because the Here's a bit of revised code for the part where you're attempting to get the labels: def __call__(self, frame):
results = super().__call__(frame) # Call the base YOLO model prediction
labels = results.names # Get class names
detected_classes = results.pandas().xyxy[0]['name'].tolist() # Get detected classes' names
annotated_frame = results.render()[0] # Get annotated frame
return annotated_frame, detected_classes In this snippet, Also, ensure you're managing resources well. For example, continually saving and playing Hope this helps you move forward with integrating gTTs into your YOLO project! 🚀 |
Beta Was this translation helpful? Give feedback.
-
Hi. I am trying to intergrate gTTs into yolo and I'm getting an Attribute error 'list' object has no attribute 'predict'
Here's my code `import cv2
from gtts import gTTS
import os
import pygame
from ultralytics import YOLO
def convert_labels_to_text(labels):
if labels:
return ", ".join(labels)
else:
return "No objects detected"
class YOLOWithLabels(YOLO):
def call(self, frame):
results = super().call(frame)
labels = results.predict[0].get_field("labels").tolist()
annotated_frame = results.render()
return annotated_frame, labels
pygame.mixer.init()
cap = cv2.VideoCapture(0)
model = YOLOWithLabels('yolov8n.pt')
while cap.isOpened():
success, frame = cap.read()
cap.release()
cv2.destroyAllWindows()
pygame.mixer.quit()
`
Beta Was this translation helpful? Give feedback.
All reactions