THU-MIG / yolov10

YOLOv10: Real-Time End-to-End Object Detection [NeurIPS 2024]
https://arxiv.org/abs/2405.14458
GNU Affero General Public License v3.0
9.89k stars 976 forks source link

How to increase number of images in /runs/detect/train/ #240

Closed aakashthapa22 closed 4 months ago

aakashthapa22 commented 5 months ago

In output i can see only three images in label pred and train. val_batch0_labels.jpg val_batch0_pred.jpg val_batch1_labels.jpg val_batch1_pred.jpg val_batch2_labels.jpg val_batch2_pred.jp train_batch0.jpg train_batch1.jpg train_batch2.jpg

In which part do I have to change the code? In addition, each image has 9 images.. how can I only display one image instead of 9. In comparison to yolov9 this looks very complex to me. train, val, detect py files are in each folder, so I could not understand anything

leonnil commented 5 months ago

Thank you for your interest! You can try changing the code below to meet your requirements: https://github.com/THU-MIG/yolov10/blob/3a53d91ec833c99d4c6215f3a67582dd2f2172a4/ultralytics/engine/trainer.py#L417 https://github.com/THU-MIG/yolov10/blob/3a53d91ec833c99d4c6215f3a67582dd2f2172a4/ultralytics/engine/validator.py#L191

aakashthapa22 commented 4 months ago

@leonnil I changed the code, however still only 3 images are saved, same as val_batch0_labels.jpg val_batch0_pred.jpg val_batch1_labels.jpg val_batch1_pred.jpg val_batch2_labels.jpg val_batch2_pred.jp train_batch0.jpg train_batch1.jpg train_batch2.jpg

For instance,

        if self.args.plots and batch_i < 51:
            self.plot_val_samples(batch, batch_i)
            self.plot_predictions(batch, preds, batch_i)

In addition, images on the result have 16 subplots. However, I only need one. When I assign value of subplot=1 it does not work. Thank you in advance.

leonnil commented 4 months ago

Hi @aakashthapa22 ,

Could you please provide your running command or script?

aakashthapa22 commented 4 months ago

@leonnil, I want to show 50 images In trainer.py, I have initialized self.plot_idx = list(range(50))

trainer.txt

In validator.py, I used if self.args.plots and batch_i < 50: self.plot_val_samples(batch, batch_i) self.plot_predictions(batch, preds, batch_i)

validator.txt

For showing 1 image each image.. for eg, val_batch1_labels.jpg and val_batch1_pred.jpg has 16 sub images in an image. I only need one. I explored \yolov10\ultralytics\utils\plotting.py I initialized max_subplot=1

plotting.txt

Thank you for helping!

leonnil commented 4 months ago

Hi @aakashthapa22 ,

It seems to work for me when I run the command yolo detect train epochs=2 batch=128 data=coco.yaml device="0,1,2,3" ...

image image image

Note that when using max_subplot=1, it seems just plot the first image in the batch

aakashthapa22 commented 4 months ago

@leonnil is there any other changes in code necessary other than this:

In trainer.py, self.plot_idx = list(range(50))

In validator.py, if self.args.plots and batch_i < 50:

In \ultralytics\utils\plotting.py max_subplots=1

I did the following changes, however, I only get 3 images.

I run the command !yolo detect train data=data.yaml model=/weights/yolov10n.pt epochs=2 batch=8 imgsz=640 device=0

I am working on my own dataset.

leonnil commented 4 months ago

Hi @aakashthapa22 ,

I did no other changes than these. Did you run pip install -e .? You can try debugging your code to ensure your changes are activated.

aakashthapa22 commented 4 months ago

@leonnil It works after running pip install -e .

I was working on kaggle and it did not work, but when I switch to PC it is working. According to my understanding, kaggle does not support pip install -e . command

Thank you for your help. I will close this issue.