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

dataloader question when ./train_mixed.sh #49

Closed
zzl777 opened this issue Oct 28, 2020 · 6 comments
Closed

dataloader question when ./train_mixed.sh #49

zzl777 opened this issue Oct 28, 2020 · 6 comments

Comments

@zzl777
Copy link

zzl777 commented Oct 28, 2020

File "train.py", line 247, in
train(args)
File "train.py", line 150, in train
train_loader = datasets.fetch_dataloader(args)
File "core/datasets.py", line 230, in fetch_dataloader
train_loader = data.DataLoader(train_dataset, batch_size=args.batch_size,
File "/data/zzl/anaconda3/envs/raft/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 224, in init
sampler = RandomSampler(dataset, generator=generator)
File "/data/zzl/anaconda3/envs/raft/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

@zachteed
Copy link
Collaborator

The dataloader isn't able to find the training dataset. Either use the directory structure in the Readme or change the dataset_path variable in datasets.py

@zzl777
Copy link
Author

zzl777 commented Oct 30, 2020

Thanks for answer. I still have some questions: 1.Does the command (./train_mixed.sh) run only when the four datasets all in the directory? If I only have two datasets(such as Sintel and DAVIS), can I train the network? 2. If I want to train another dataset(my private dataset), what should I do? Thanks!!!

@zachteed
Copy link
Collaborator

You can modify the function

def fetch_dataloader(args, TRAIN_DS='C+T+K+S+H'):

to

 def fetch_dataloader(args, TRAIN_DS='C+T+K+S+H'):
       aug_params = {'crop_size': args.image_size, 'min_scale': -0.2, 'max_scale': 0.6, 'do_flip': True}
       sintel_clean = MpiSintel(aug_params, split='training', dstype='clean')
       sintel_final = MpiSintel(aug_params, split='training', dstype='final')
       train_dataset = sintel_clean + sintel_final
       train_loader = data.DataLoader(train_dataset, batch_size=args.batch_size, 
           pin_memory=False, shuffle=True, num_workers=4, drop_last=True)

      print('Training with %d image pairs' % len(train_dataset))
      return train_loader

to train only using sintel data. To train on another dataset, you will need to write your own subclass of FlowDataset

@zzl777
Copy link
Author

zzl777 commented Oct 31, 2020

Thanks again for your answer! I modified the function to train only using Sintel dataset. However, there exists another question during training:
Traceback (most recent call last):
File "train.py", line 247, in
train(args)
File "train.py", line 192, in train
results.update(evaluate.validate_chairs(model.module))
File "/data/zzl/anaconda3/envs/raft/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
return func(*args, **kwargs)
File "/data/zzl/PycharmProjects/RAFT/evaluate.py", line 90, in validate_chairs
epe = np.mean(np.concatenate(epe_list))
File "<array_function internals>", line 5, in concatenate
ValueError: need at least one array to concatenate
what should I do to address it? thanks a lot!

@zachteed
Copy link
Collaborator

zachteed commented Oct 31, 2020

In the training command, you need to change the flag to specify the validation dataset, from --validation chairs to --validation sintel

@zzl777
Copy link
Author

zzl777 commented Nov 2, 2020

Thanks again for your answer! If I want to save all the output flow images in a directory (just flow images, not an original frame on the top and a flow image on the below in the output of demo.py), what should I do? thanks a lot!

@zachteed zachteed closed this as completed Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants