tasks/classify/ #7960
Replies: 41 comments 135 replies
-
I have a pretrained model that can do detection and segmentation with my custom dataset, Can the model continue be trained for classification purpose, and predicts by passing the |
Beta Was this translation helpful? Give feedback.
-
I think you need to modify the dataset structure to be compatible with Detection as @pderrenger stated and might need to use |
Beta Was this translation helpful? Give feedback.
-
i want solo object detection code for video then want to merge my object half identification code status = False
|
Beta Was this translation helpful? Give feedback.
-
I trained a yolov8-l classification model where I was perform classification on some images, few months back it was working perfectly fine, was classifying accurately, but few days ago, when I ran the model again on an image I got an error, something like this This is the code, where I am loading a trained model .pt file from ultralytics import YOLO model = YOLO('/content/drive/MyDrive/best.pt') And Getting error like this: AttributeError Traceback (most recent call last) 9 frames AttributeError: shape Cant figure out this error, Kindly If anyone could help with this. |
Beta Was this translation helpful? Give feedback.
-
i have 73 bad images and 4000 good images, can yolov8 work for this or not (For classification problem), if yes , then what i will do ? |
Beta Was this translation helpful? Give feedback.
-
What are the main differences in the model architecture of Classify and Detect? |
Beta Was this translation helpful? Give feedback.
-
Hi there! TL;DR - After debug into train.py & predict.py, realized the images are resized + cropped strangely from what I gathered in the docs/forums, even with specified imgsz and rect=True. Full explanation - Training was : Expectations : (Even when I tried to do imgsz as a tuple - (h,w) aka (292,1216), a warning showed up, telling me the imgsz will be automatically selected to 1216, as it should have been an integer.. not a tuple.) What actually happened : Meaning, what previously was image of size 1216x292, turned into image of size 5063x1216 (This is due to Resize transformation of pytorch) And its not over - the data taken was only the INNER 1216x1216 - less than 1/4 of the actual data.. (This is due to CenterCrop transformation of pytorch) So, basically, I am asking - Is there a quote from the docs I have missed that said classify must be square sized? Or is there another way (except from padding to 1216x1216 - adding 924 black pixels to the height), to make classify work with rectangular images? Thank you so much, and sorry if I wasnt clear.. hopefully it was. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have identified a small issue in the example provided for training in the classification task, which is 'results = model.train(data='mnist160', epochs=100, imgsz=64)'. The parameter 'imgsz' should actually be 640. |
Beta Was this translation helpful? Give feedback.
-
When I try to train my custom data, it raised Runtime Error
while in my yaml file is
why it did not go into train folder? |
Beta Was this translation helpful? Give feedback.
-
Hello, ı hope your day is going well.
I run this code and ı get max 0.764 acc. I want to improve my acc value. I changed optimizer but it did not improve. What should ı do. Please help me :(( Load a modelmodel = YOLO("yolov8x-cls.pt") # load a pretrained model Train the model and save the resultsresults = model.train(data='/content/data', epochs=200, imgsz=224, scale=0) |
Beta Was this translation helpful? Give feedback.
-
How would i write a custom loss function to be used only during training, and the default loss for validation? I tried this in tasks.py def init_criterion(self):
"""Initialize the loss criterion for the ClassificationModel."""
return v8ClassificationCustomLoss(self) if self.training else v8ClassificationLoss() |
Beta Was this translation helpful? Give feedback.
-
Hello, can a pretrained detection model be modified and applied to a classification task? |
Beta Was this translation helpful? Give feedback.
-
Rewrite: I have an image classification use case where the images could belong to class 1 or class 2, both class 1 and class 2 and neither. What's the best way to setup this classification using ultralytics image classifiers? Currently I have 4 folders class 1, class2, both, neither. Can you provide suggestions? |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I wanted to train a classification model on my custom datset. When i run the code i get this error Traceback (most recent call last):
Could you please tell what mistake im making here? |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Is there a version trained on Open Images V7 like yolov8n-oiv7? |
Beta Was this translation helpful? Give feedback.
-
Can yolov11 image classification on human facial expression like happy vs. sad? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hello YOLO team. Can I know which parts of the image that yolo classification model sees in form of heatmaps? Thanks. I basically want to answer the question why! |
Beta Was this translation helpful? Give feedback.
-
Hello https://i.ibb.co/s3qZxCy/Figure-1.png |
Beta Was this translation helpful? Give feedback.
-
Hello, I keep getting this error when tuning a yolov8-cls classification model with wandb. TensorBoard: model graph visualization added ✅
Traceback (most recent call last): AdditionalEnvironment information: Basic code: !pip install -U ultralytics from ultralytics import YOLO wandb.agent(sweep_id, train, count=10). |
Beta Was this translation helpful? Give feedback.
-
I have an issue when exporting with batch
After that, I am trying to run a sample code that is generated when exporting the model
But it crashed.
I want to know what is a solution to fix it ??? |
Beta Was this translation helpful? Give feedback.
-
Ultralytics 8.3.58 🚀 Python-3.10.12 torch-2.5.1+cu121 CPU (Intel Xeon 2.20GHz)
0 -1 1 464 ultralytics.nn.modules.conv.Conv [3, 16, 3, 2]
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Is it possible to use an object detection model for classification? I would like to test my model in an application that does classification only and the model I have was trained for object detection. |
Beta Was this translation helpful? Give feedback.
-
Hey! Junior here. Does size=224 means this model can only be trained using 224x224? So, if have dataset of 640x40 I need resize it? Also, does this hold same during inference? |
Beta Was this translation helpful? Give feedback.
-
While running validation code, I encountered this error:
Ultralytics 8.3.99 🚀 Python-3.13.2 torch-2.6.0+cpu CPU (Intel Core(TM)
i3-3220T 2.80GHz)
YOLO11s summary (fused): 100 layers, 9,419,766 parameters, 0 gradients,
21.3 GFLOPs
Traceback (most recent call last):
File "c:\Users\User\Desktop\classify\invoice\val.py", line 8, in <module>
metrics = model.val() # no arguments needed, dataset and settings
remembered
File
"C:\Users\krispy\Desktop\classify\invoice\.venv\Lib\site-packages\ultralytics\engine\model.py",
line 628, in val
validator(model=self.model)
~~~~~~~~~^^^^^^^^^^^^^^^^^^
File
"C:\Users\User\Desktop\classify\invoice\.venv\Lib\site-packages\torch\utils\_contextlib.py",
line 116, in decorate_context
return func(*args, **kwargs)
File
"C:\Users\User\Desktop\classify\invoice\.venv\Lib\site-packages\ultralytics\engine\validator.py",
line 179, in __call__
self.data = check_det_dataset(self.args.data)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File
"C:\Users\User\Desktop\classify\invoice\.venv\Lib\site-packages\ultralytics\data\utils.py",
line 312, in
check_det_dataset
file = check_file(dataset)
File
"C:\Users\krispy\Desktop\classify\invoice\.venv\Lib\site-packages\ultralytics\utils\checks.py",
line 546, in check_file
raise FileNotFoundError(f"'{file}' does not exist")
FileNotFoundError: '/content/datasets/invoice/data.yaml' does not exist
It says '/content/datasets/invoice/data.yaml' does not exist so I created a
content folder inside my project and then datasets, invoice, and finally
pasted data.yml inside invoice.
However, I think the confusion lies in
'/content/datasets/invoice/data.yaml' vs
'content/datasets/invoice/data.yaml'.
'
…On Mon, Mar 31, 2025 at 1:04 AM Glenn Jocher ***@***.***> wrote:
Hi there! For classification confidence scores, access
results[0].probs.top1conf to get the top confidence value and
results[0].names for class names. The Predict page shows how to work with
classification outputs. Let us know if you need more help! 😊
—
Reply to this email directly, view it on GitHub
<#7960 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BLSKYGZOZAFWC5334JZBAUT2XA7UVAVCNFSM6AAAAABCV6KUCGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRWHEZTAOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Okay thank you for the clarification. What about object detection model
then?
Also, I have another question for you. Earlier you said the model will
convert the input images to its requirement size i.e. 224.
So, the time to train a model using 2000x2000 documents and 224x2224
documents would be the same? I also wonder why the input image is expected
to be a square (having same width and height).
…On Mon, Mar 31, 2025 at 9:30 PM Glenn Jocher ***@***.***> wrote:
@test726 <https://github.com/test726> hi there! For classification
validation, ensure your dataset follows the YOLO classification format (no
YAML needed) and use the correct relative path to your dataset folder. The
CLI command should be `yolo classify val model=path/to/
—
Reply to this email directly, view it on GitHub
<#7960 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BLSKYGZ4LLHHD632OANCSED2XFPI5AVCNFSM6AAAAABCV6KUCGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRXHA2DKMY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
is classify train only working on a single GPU? |
Beta Was this translation helpful? Give feedback.
-
I am trying to train classification model. why you prefer you architecture. why don't you move transformer architecture? is it capable than ViT. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
tasks/classify/
Learn about YOLOv8 Classify models for image classification. Get detailed information on List of Pretrained Models & how to Train, Validate, Predict & Export models.
https://docs.ultralytics.com/tasks/classify/
Beta Was this translation helpful? Give feedback.
All reactions