-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The recognition result of classify/predict.py is very poor? #9462
Comments
👋 Hello @small-code-cat, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit. |
The dataset I use is minist. I hope someone can help me |
@small-code-cat MNIST training runs correctly for me. I see 97.5% top 1 accuracy after two epochs with all default settings. |
@small-code-cat training is at imgsz 128, so you might want to predict at the same size. |
I don't quite understand. I didn't specify imgsz during training. Why do I need to specify when predicting? Isn't this automatically processed by the framework? |
@small-code-cat see train.py and predict.py argparsers for details, i.e.: Lines 183 to 206 in 4d50cd3
|
Thank you very much, it helped me a lot, it turns out that the imgsz of the two codes are not the same |
@small-code-cat ClassificationModel and SegmentationModel types are not yet fully supported by AutoShape, but you can still load them with PyTorch Hub and pass them torch tensors. Note you must apply your own pre and post processing: |
To match classify/val.py and classify/predict.py Helps #9462 Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Update ClassificationModel default training imgsz=224 To match classify/val.py and classify/predict.py Helps #9462 Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@small-code-cat good news 😃! Your original issue may now be partially resolved ✅ in PR #9469. This PR aligns all default Classification task image sizes at 224 pixels. This should help avoid confusion in the future. Note that many datasets like MNIST with very small image sizes (i.e. 28x28 pixels) can achieve good results at lower image resolutions like --imgsz 128, but ImageNet default is 224. To receive this update:
Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀! |
Thank you very much, this update is very useful, I hope yolov5 can do better and better, cheers! |
I tried it and it's running, thanks a lot! |
@small-code-cat perhaps your paths are incorrect. I would just load as in the default example from ultralytics/yolov5 |
I have tried this, and I will report this error. |
So is there any way to solve this problem? |
The problem has been solved, because I have a python file called utils in the same level directory, change the name and it is solved |
How do you remove the last few prediction layers when loading the model? I want to use some of the layers to do kmeans clustering |
@small-code-cat you can access the model's layers through the model's import torch
from models.yolo import Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Access the actual YOLOv5 PyTorch model
yolo_model = model.model
# Remove the last few prediction layers
yolo_model.model[-1].pop() # Remove the last layer from the YOLO layer list
yolo_model.model[-1].pop() # Remove the second-to-last layer from the YOLO layer list
# Perform kmeans clustering using the modified model
# ... Please note that modifying the model in this way will alter its behavior, so it's important to understand the implications of removing specific layers. For more details on working with the YOLOv5 PyTorch model, you can refer to the Ultralytics YOLOv5 documentation. |
Search before asking
Question
I use classify/train.py to train the target classification, the model I have used yolov5s-cls.pt and efficient_v2_s, the first model was trained 50 times and the second one was trained 10 times. The loss has been decreasing and the accuracy is also good; however, the results of classify/predict.py are very poor
The prediction results are as follows.
Additional
No response
The text was updated successfully, but these errors were encountered: