ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.51k stars 16.08k forks source link

AttributeError: 'DetectMultiBackend' object has no attribute 'input_details' #13204

Open Kelly02140 opened 1 month ago

Kelly02140 commented 1 month ago

Search before asking

Question

Hello, I am doing a YOLOv5 project with DeepSort added to give each detected object a unique ID. I use yolov5n.pt as the weight to test a short video and It all works well. However, when I try to put my own trained weight profile to test the video, it gives me this error: 'AttributeError: 'DetectMultiBackend' object has no attribute 'input_details' Could anyone help me with this problem? image image

Additional

No response

glenn-jocher commented 1 month ago

@Kelly02140 hello,

Thank you for reaching out and providing detailed information about your issue.

The error AttributeError: 'DetectMultiBackend' object has no attribute 'input_details' typically occurs when there is a mismatch between the code and the model weights being used. Here are a few steps to help troubleshoot and resolve this issue:

  1. Update YOLOv5 Repository: Ensure you are using the latest version of the YOLOv5 repository. You can update your local repository by running:

    git pull
  2. Verify Model Compatibility: Make sure that the custom-trained weights are compatible with the version of YOLOv5 you are using. Sometimes, weights trained on older versions may not be compatible with newer code.

  3. Check for Model Conversion: If you have converted your model to another format (e.g., TensorFlow, ONNX), ensure that the conversion process was successful and that the model is correctly loaded.

  4. Re-train or Re-export Weights: If the issue persists, consider re-training your model or re-exporting the weights using the latest YOLOv5 codebase.

  5. Example Code: Here is a snippet to ensure you are loading the model correctly:

    from yolov5 import YOLOv5
    
    # Load model
    model = YOLOv5('path/to/your/custom/weights.pt')
    
    # Perform inference
    results = model('path/to/your/video.mp4')
  6. Environment Check: Ensure that your environment has all the required dependencies updated. You can do this by running:

    pip install -r requirements.txt

If you have verified all the above steps and the issue still persists, please provide additional details such as the exact steps you followed to train and export your custom weights. This will help in diagnosing the problem more effectively.

Feel free to reach out if you have any further questions or need additional assistance. The YOLO community and the Ultralytics team are here to help! 😊