NVlabs / Deep_Object_Pose

Deep Object Pose Estimation (DOPE) – ROS inference (CoRL 2018)
Other
1.03k stars 287 forks source link

Fix ValueError: num_samples error #212

Closed Branden-Kang closed 2 years ago

Branden-Kang commented 2 years ago

I fixed a minor bug.

When I command, python train.py --data ~/branden/Deep_Object_Pose/scripts/nvisii_data_gen/output/example --object my_custom_object --epochs 60 --gpuids 0 There is the error below:

Error: Traceback (most recent call last): File "train.py", line 1184, in trainingdata = torch.utils.data.DataLoader(train_dataset, File "/home/work/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 224, in init sampler = RandomSampler(dataset, generator=generator) File "/home/work/.local/lib/python3.8/site-packages/torch/utils/data/sampler.py", line 95, in init raise ValueError("num_samples should be a positive integer " ValueError: num_samples should be a positive integer value, but got num_samples=0

I found the solution: change the png to jpeg

However, in my case, this solution didn't work and I found that .ipynb_checkpoints file was created. ['/home/branden/Deep_Object_Pose/scripts/nvisii_data_gen/output/example/.ipynb_checkpoints']

In this case, the training codes doesn't work. Therefore, I fixed the bug.

TontonTremblay commented 2 years ago

I am not sure there is a bug there? If you only have a single folder it wont load the data. You need 2 or more with your version of the code.

Branden-Kang commented 2 years ago

I don't think there is a fatal bug. I think this is my special case. I used JupyterLab for training my custom objects.

When I ran my codes, it didn't work. so, I checked all the files in my training dataset folder. There are only png and json files.

image

However, when I took a close look and checked the hidden files, there is .ipynb_checkpoints: ['/home/branden/Deep_Object_Pose/scripts/nvisii_data_gen/output/example/.ipynb_checkpoints']

image

Because of this hidden file, my png files weren't converted into jpg files. As you see the codes below, add_json_files are used when there is no file in our training dataset.

image

Therefore, my trick is below:

line #361: len(folders)>0 -> len(folders)>1

Any other solutions that ignore .ipynb_checkpoints would be great.

I spent time fixing this problem. So, if someone has the same issue, I hope it helps them.

mintar commented 2 years ago

I've added a better solution to this problem in #223. If that PR is merged, then this PR can be closed without merging.

TontonTremblay commented 2 years ago

Sorry for some reason I did not see your message earlier @Branden-Kang. I think it felt around the siggraph deadline. Thank you @mintar.