Skip to content
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

Very very urgent help required Yolov8 classification issue #12676

Open
1 task done
anut123 opened this issue May 14, 2024 · 9 comments
Open
1 task done

Very very urgent help required Yolov8 classification issue #12676

anut123 opened this issue May 14, 2024 · 9 comments
Labels
question Further information is requested

Comments

@anut123
Copy link

anut123 commented May 14, 2024

Search before asking

Question

In yolov8 classification model and it is for custom dataset I need two classes for example if I have horse video so it is need to classify eating horse or not eating horse and after I have train the classification model for horse then I am getting the output example as if i take horse video then output is classifying eating-horse 0.56 so on and not eating horse 0.97 but it should classify eating horse as 0.97 and not eating horse as 0.56 sometimes I am getting correct answer and sometimes I am getting wrong output of eating horse video
And if I take not eating horse video then the output is classifying as not eating 0.89 and eating 0.34 and sometimes it classify as not eating 0.45 and eating 0.89 I mean sometimes it is showing correct output results and sometimes not showing correct output results
For training the model i have used train command of classification model yolov8 I have done hypertuning parameter also and I have trained the model with more epochs still the same issue and the images are of 50k for horse animal
I have tired multiple ways and i have tired alott but I couldn't find any solution yet it would be grateful if anyone could help me out with this

for training the model of classification yolov8 i have used this command
!yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=64 optimizer=Adam dropout=0.2

@glenn-jocher
@RizwanMunawar
Very very urgent help required

Additional

No response

@anut123 anut123 added the question Further information is requested label May 14, 2024
@anut123 anut123 changed the title Yolov8 classification issue Very very urgent help required Yolov8 classification issue May 14, 2024
@glenn-jocher
Copy link
Member

Hi there! It looks like your classification model is experiencing some inconsistency with the predictions. Here are a few suggestions that might help improve the stability of your results:

  1. Review your dataset: Ensure that the labels are correctly assigned and that your dataset is balanced in terms of the distribution between the two classes.

  2. Modify the Image Size: You might want to experiment with a larger image size than imgsz=64 if your computational resources allow. This can sometimes help the model capture more details and improve accuracy.

  3. Fine-tune the Model: Since you have already trained for many epochs, consider using a slightly lower learning rate to fine-tune the model, which can sometimes help refine the predictions.

  4. Model Evaluation: Evaluate your model’s confusion matrix to see if there's a pattern in misclassifications that can give more insights.

Here's a modified training command you might consider using:

!yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=128 optimizer=Adam dropout=0.2 lr=0.001

This uses a larger image size and a reduced learning rate, which might help in your case. Let's see if these changes influence the consistency of your predictions! 🚀

@anut123
Copy link
Author

anut123 commented May 14, 2024

i have run the training command the command you gave to run it ----> !yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=128 optimizer=Adam dropout=0.2 lr=0.001 after using this command i am getting this error Traceback (most recent call last):
File "/usr/local/bin/yolo", line 8, in
sys.exit(entrypoint())
File "/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/init.py", line 516, in entrypoint
check_dict_alignment(full_args_dict, overrides)
File "/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/init.py", line 323, in check_dict_alignment
raise SyntaxError(string + CLI_HELP_MSG) from e
SyntaxError: 'lr' is not a valid YOLO argument. Similar arguments are i.e. ['lrf=0.01', 'lr0=0.01'].

Arguments received: ['yolo', 'task=classify', 'mode=train', 'model=yolov8m-cls.pt', 'data=/content/sheep_data', 'epochs=120', 'imgsz=128', 'optimizer=Adam', 'dropout=0.2', 'lr=0.001']. Ultralytics 'yolo' commands use the following syntax:

    yolo TASK MODE ARGS

    Where   TASK (optional) is one of {'segment', 'detect', 'classify', 'obb', 'pose'}
            MODE (required) is one of {'track', 'train', 'benchmark', 'export', 'val', 'predict'}
            ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
                See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'

1. Train a detection model for 10 epochs with an initial learning_rate of 0.01
    yolo train data=coco8.yaml model=yolov8n.pt epochs=10 lr0=0.01

2. Predict a YouTube video using a pretrained segmentation model at image size 320:
    yolo predict model=yolov8n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320

3. Val a pretrained detection model at batch-size 1 and image size 640:
    yolo val model=yolov8n.pt data=coco8.yaml batch=1 imgsz=640

4. Export a YOLOv8n classification model to ONNX format at image size 224 by 128 (no TASK required)
    yolo export model=yolov8n-cls.pt format=onnx imgsz=224,128

6. Explore your datasets using semantic search and SQL with a simple GUI powered by Ultralytics Explorer API
    yolo explorer

5. Run special commands:
    yolo help
    yolo checks
    yolo version
    yolo settings
    yolo copy-cfg
    yolo cfg

@glenn-jocher @RizwanMunawar @AyushExel kindly help as earliest as possible because currently my work has been stucked it would be grateful if you could help me out with this

@glenn-jocher
Copy link
Member

Hey there! 👋 It looks like there’s a small mix-up with the argument for the learning rate. In YOLOv8 CLI, the learning rate should be specified as lr0 instead of lr.

You can correct your command as follows:

!yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=128 optimizer=Adam dropout=0.2 lr0=0.001

Give this a try and let me know if it resolves the issue! If you run into anything else, feel free to reach out. Happy training! 🚀

@anut123
Copy link
Author

anut123 commented May 15, 2024

Okay sure I will try and let you know @glenn-jocher

@glenn-jocher
Copy link
Member

@anut123 great! Looking forward to hearing how it goes! If you have any more questions or need further assistance, don't hesitate to ask. Happy coding! 😊

@workanusha1
Copy link

for example if I have horse video so it is need to classify eating horse or not eating horse and after I have train the classification model for horse then I am getting the output example as if i take horse video then output is classifying eating-horse 0.56 so on and not eating horse 0.97 but it should classify eating horse as 0.97 and not eating horse as 0.56 sometimes I am getting correct answer and sometimes I am getting wrong output of eating horse video
And if I take not eating horse video then the output is classifying as not eating 0.89 and eating 0.34 and sometimes it classify as not eating 0.45 and eating 0.89 I mean sometimes it is showing correct output results and sometimes not showing correct output results. and after using your command --> !yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=128 optimizer=Adam dropout=0.2 lr0=0.001 I have tired multiple ways and i have tired alot but I couldn't find any solution yet it would be grateful if anyone could help me out with this
@glenn-jocher

@glenn-jocher
Copy link
Member

Hi there! It sounds like your model might be experiencing some inconsistency in its predictions. This could be due to various factors such as model overfitting, insufficient or imbalanced training data. You might want to try a few things:

  1. Ensure your dataset is well-balanced between the two classes.
  2. Experiment with different model architectures or tweak the hyperparameters further.
  3. Consider using data augmentation to increase the diversity of your training data.

Here's a quick tweak to your training command to include more data augmentation:

!yolo task=classify mode=train model=yolov8m-cls.pt data='{DATA_DIR}' epochs=120 imgsz=128 optimizer=Adam dropout=0.2 lr0=0.001 augment=True

Hope this helps! Let us know how it goes. 😊

@workanusha1
Copy link

sure will let know @glenn-jocher

@glenn-jocher
Copy link
Member

Sounds good! Looking forward to your update. If you need any more help, just let us know! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants