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

train-yolos error #22

Closed
1 of 2 tasks
robmarkcole opened this issue Dec 14, 2022 · 13 comments
Closed
1 of 2 tasks

train-yolos error #22

robmarkcole opened this issue Dec 14, 2022 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@robmarkcole
Copy link

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Notebook name

train-yolos-huggingface-object-detection-on-custom-data.ipynb

Bug

I am using my own dataset from roboflow, exported in coco format.

At:

#Setup dataloader for training loop

from torch.utils.data import DataLoader

def collate_fn(batch):
  pixel_values = [item[0] for item in batch]
  encoding = feature_extractor.pad(pixel_values, return_tensors="pt")
  labels = [item[1] for item in batch]
  batch = {}
  batch['pixel_values'] = encoding['pixel_values']
  batch['labels'] = labels
  return batch

train_dataloader = DataLoader(train_dataset, collate_fn=collate_fn, batch_size=1, shuffle=True)
val_dataloader = DataLoader(val_dataset, collate_fn=collate_fn, batch_size=1)
batch = next(iter(train_dataloader))

I get error:

The `max_size` parameter is deprecated and will be removed in v4.26. Please specify in `size['longest_edge'] instead`.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-7-bd1a63ffeba0>](https://localhost:8080/#) in <module>
     14 train_dataloader = DataLoader(train_dataset, collate_fn=collate_fn, batch_size=1, shuffle=True)
     15 val_dataloader = DataLoader(val_dataset, collate_fn=collate_fn, batch_size=1)
---> 16 batch = next(iter(train_dataloader))

7 frames
[/usr/local/lib/python3.8/dist-packages/transformers/models/yolos/image_processing_yolos.py](https://localhost:8080/#) in resize(self, image, size, resample, data_format, **kwargs)
    805             size = (size["height"], size["width"])
    806         else:
--> 807             raise ValueError(
    808                 "Size must contain 'height' and 'width' keys or 'shortest_edge' and 'longest_edge' keys. Got"
    809                 f" {size.keys()}."

ValueError: Size must contain 'height' and 'width' keys or 'shortest_edge' and 'longest_edge' keys. Got dict_keys(['shortest_edge']).

Environment

Colab

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@robmarkcole robmarkcole added the bug Something isn't working label Dec 14, 2022
@SkalskiP
Copy link
Collaborator

Hi, @robmarkcole 👋🏻! Thank you very much for your interest in Roboflow Notebooks! Please have a little patience. I'm taking a look at your problem, but it may take some time to figure out what's happening. I'll keep you posted.

@SkalskiP SkalskiP self-assigned this Dec 14, 2022
@SkalskiP
Copy link
Collaborator

Hello again @robmarkcole 👋🏻! I confirm that the train-yolos-huggingface-object-detection-on-custom-data.ipynb notebook does not work even with our own dataset right now. Judging by logs coming from transformers and pytorch-lightning most likely because of some pip package update. We will work on fixing that issue with the rest of the team.

@SkalskiP
Copy link
Collaborator

I just released a fix for train-yolos-huggingface-object-detection-on-custom-data.ipynb. I tried it on Google Colab and it works for me. Please take a look, and let me know if you stil experience issues you described.

@robmarkcole
Copy link
Author

OK run the new notebook and seems OK. Just noted the change to accelerator='gpu', devices=1

@robmarkcole
Copy link
Author

@SkalskiP I just noticed batch_size=1 which is an odd choice

@SkalskiP
Copy link
Collaborator

I'm not sure why @Jacobsolawetz decided to use batch_size=1. Maybe problems with GPU memory overflow. Glad to hear that everything works.

@i-m-karanagarwal
Copy link

@SkalskiP I tried to run the notebook with my own dataset but it showed the same error.
Could you please check what's causing it?

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jan 4, 2023

@i-m-karanagarwal just to be sure, could you send me a link to Google Colab that you are using?

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jan 4, 2023

@i-m-karanagarwal, could you grant me access? I just requested :)

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jan 4, 2023

Okay, I know what's going on! :) This is an old version of the notebook, before the fix. Please use this version: https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolos-huggingface-object-detection-on-custom-data.ipynb

@i-m-karanagarwal, could you please let me know where did you found the link to that version? We need to update that link so that others wouldn't struggle with the same errors :)

@i-m-karanagarwal
Copy link

Okay okay
@SkalskiP I found the old version on the documentation site of Roboflow Under YoloS model.

@SkalskiP
Copy link
Collaborator

SkalskiP commented Jan 4, 2023

Thank you very much 🙏🏻 @i-m-karanagarwal! I'll make sure that this time the link gets updated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants