-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
I got a runtimerror when I run classifier.py to train my own dataset. #2438
Comments
@UNeedCryDear pytorch 1.8.0 uses the new 'fill' term, and the code has been updated to the 1.8.0 standard recently. Correct usage of the file is shown in the comments at the top, you can use this to get started: Lines 1 to 2 in 058d667
|
@glenn-jocher It's OK to run MNIST with pytorch1.7.1, but once I run my own dataset to train my calssifiter, it will report a runtimeError: |
@UNeedCryDear if everything works with MNIST, CIFAR, etc, and then it stops working on your custom dataset, the culprit would be your dataset. I'm not sure there's anything I can do about your dataset other than to recommend you use the existing datasets as templates to get started with your custom dataset. |
@glenn-jocher Thank you for your work. I also encountered this situation. It could run on MNIST, but when I changed the size of an image in MNIST,I would report an error:
28X28 is the size of MNIST size,522X523 is changed. Line 59 in 058d667
|
@CE-Noob @UNeedCryDear if you are passing in differently shaped images for classifier training you'll need to update both the train and testloaders appropriately in order that they output all identically shaped images, otherwise the batching operation will fail: Lines 54 to 63 in 058d667
EDIT: remember current testloader is slicing trainloader for last two ops only, so you'll need to include the resize op in testloader. |
@glenn-jocher Thanks. |
@UNeedCryDear Hi, i also face that fill problem and data directory problem. Could you guide me to get classifier weights? Thanks! |
@mmez-11 I can't make format right. But you should be able to understand how to modify it. |
@UNeedCryDear Thanks for your kindness but i am still in problem. i got this prob below! |
@mmez-11 #2438 (comment) |
It's me again.
First,The compiler will report an error of“fill”. This should not be fill, but fillcolor() in the old classifer.py.
yolov5/classifier.py
Line 58 in 058d667
Second,after I change fill to fillcolor, it's OK to run MNIST, but once I run my own data, it will report an error. The error message is as follows:
`epoch gpu_mem train_loss val_loss accuracy
1/50 0.124G 3.23 : 97%|█████████▋| 34/35 [00:19<00:00, 1.72it/s]
Traceback (most recent call last):
File "D:/PyCharm/yolov5-classifier/classifier.py", line 240, in
train()
File "D:/PyCharm/yolov5-classifier/classifier.py", line 145, in train
fitness = test(model, testloader, names, criterion, pbar=pbar) # test
File "D:/PyCharm/yolov5-classifier/classifier.py", line 184, in test
for images, labels in dataloader:
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 435, in next
data = self._next_data()
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 1085, in _next_data
return self._process_data(data)
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 1111, in _process_data
data.reraise()
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch_utils.py", line 428, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data_utils\worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 47, in fetch
return self.collate_fn(data)
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data_utils\collate.py", line 83, in default_collate
return [default_collate(samples) for samples in transposed]
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data_utils\collate.py", line 83, in
return [default_collate(samples) for samples in transposed]
File "C:\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data_utils\collate.py", line 55, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [3, 90, 59] at entry 0 and [3, 37, 25] at entry 1
`
How to solve this problem?
The text was updated successfully, but these errors were encountered: