shrubb / latent-pose-reenactment

The authors' implementation of the "Neural Head Reenactment with Latent Pose Descriptors" (CVPR 2020) paper.
https://shrubb.github.io/research/latent-pose-reenactment/
Apache License 2.0
180 stars 34 forks source link

FileNotFoundError #14

Closed mayanktiwariiiitdmj closed 3 years ago

mayanktiwariiiitdmj commented 3 years ago

sir, when I am running train.py from the following script:

# in this example, your images should be "$DATASET_ROOT/images-cropped/$IDENTITY_NAME/*.jpg"
DATASET_ROOT="DATASET_ROOT"
IDENTITY_NAME="personA"
MAX_BATCH_SIZE=8             # pick the largest possible, start with 8 and decrease until it fits in VRAM
CHECKPOINT_PATH="checkpoints/latent-pose-release.pth"
OUTPUT_PATH="outputs/"       # a directory for outputs, will be created
RUN_NAME="tony_hawk_take_1"  # give your run a name if you want

# Important. See the note below
TARGET_NUM_ITERATIONS=230

# Don't change these
NUM_IMAGES=`ls -1 "$DATASET_ROOT/images-cropped/$IDENTITY_NAME" | wc -l`
BATCH_SIZE=$((NUM_IMAGES<MAX_BATCH_SIZE ? NUM_IMAGES : MAX_BATCH_SIZE))
ITERATIONS_IN_EPOCH=$(( NUM_IMAGES / BATCH_SIZE ))

mkdir -p $OUTPUT_PATH

python train.py \
    --config finetuning-base                 \
    --checkpoint_path "$CHECKPOINT_PATH"     \
    --data_root "$DATASET_ROOT"              \
    --train_split_path "$IDENTITY_NAME"      \
    --batch_size $BATCH_SIZE                 \
    --num_epochs $(( (TARGET_NUM_ITERATIONS + ITERATIONS_IN_EPOCH - 1) / ITERATIONS_IN_EPOCH )) \
    --experiments_dir "$OUTPUT_PATH"         \
    --experiment_name "$RUN_NAME"

Then I am getting the following error:

PID 2869 - 2021-03-24 11:45:10,551 - INFO - utils.load_config_file - Using config configs/finetuning-base.yaml
PID 2869 - 2021-03-24 11:45:10,554 - INFO - utils.get_args_and_modules - Loading checkpoint file checkpoints/latent-pose-release.pth
PID 2869 - 2021-03-24 11:45:15,676 - INFO - utils.setup - Random Seed: 123
PID 2869 - 2021-03-24 11:45:15,677 - INFO - train.py - Initialized the process group, my rank is 0
PID 2869 - 2021-03-24 11:45:15,677 - INFO - train.py - Loading dataloader 'voxceleb2_segmentation_nolandmarks'
PID 2869 - 2021-03-24 11:45:15,983 - INFO - dataloaders.common.voxceleb.get_part_data (train) - Determining the 'train' data source
PID 2869 - 2021-03-24 11:45:15,983 - INFO - dataloaders.common.voxceleb.get_part_data (train) - Checking if 'DATASET_ROOT/images-cropped/personA' is a directory...
PID 2869 - 2021-03-24 11:45:15,983 - INFO - dataloaders.common.voxceleb.get_part_data (train) - Yes, it is; the only train identity will be 'personA'
PID 2869 - 2021-03-24 11:45:16,003 - INFO - dataloaders.common.voxceleb.get_part_data (train) - This dataset has 1184 images
PID 2869 - 2021-03-24 11:45:16,003 - INFO - dataloaders.common.voxceleb.get_part_data (train) - Setting `args.num_labels` to 1 because we are fine-tuning or the model has been fine-tuned
PID 2869 - 2021-03-24 11:45:16,016 - WARNING - dataloader - Could not find the '.npy' file with bboxes, will assume the images are already cropped
PID 2869 - 2021-03-24 11:45:16,016 - INFO - dataloaders.augmentation - Pixelwise augmentation: True
PID 2869 - 2021-03-24 11:45:16,016 - INFO - dataloaders.augmentation - Affine scale augmentation: True
PID 2869 - 2021-03-24 11:45:16,016 - INFO - dataloaders.augmentation - Affine shift augmentation: True
PID 2869 - 2021-03-24 11:45:16,030 - INFO - dataloaders.dataloader - This process will receive a dataset with 1184 samples
PID 2869 - 2021-03-24 11:45:16,030 - INFO - train.py - Starting from checkpoint checkpoints/latent-pose-release.pth
PID 2869 - 2021-03-24 11:45:16,030 - INFO - utils.load_model_from_checkpoint - Loading embedder 'unsupervised_pose_separate_embResNeXt_segmentation'
PID 2869 - 2021-03-24 11:45:20,137 - INFO - utils.load_model_from_checkpoint - Loading generator 'vector_pose_unsupervised_segmentation_noBottleneck'
PID 2869 - 2021-03-24 11:45:20,531 - INFO - utils.load_model_from_checkpoint - Loading discriminator 'no_landmarks'
PID 2869 - 2021-03-24 11:45:21,225 - WARNING - utils.load_model_from_checkpoint - Discriminator has changed in config (maybe due to finetuning), so not loading `optimizer_D`
PID 2869 - 2021-03-24 11:45:21,225 - INFO - utils.load_model_from_checkpoint - Loading runner holycow
PID 2869 - 2021-03-24 11:45:21,225 - WARNING - utils.load_model_from_checkpoint - Embedder or generator has changed in config, so not loading `optimizer_G`
PID 2869 - 2021-03-24 11:45:21,229 - INFO - train.py - Starting from iteration #2714183
PID 2869 - 2021-03-24 11:45:25,641 - WARNING - runner - Parameters mismatch in generator and the initial value of weights' running averages. Initializing by cloning
PID 2869 - 2021-03-24 11:45:25,645 - INFO - train.py - For fine-tuning, computing an averaged identity embedding from 1184 frames
Traceback (most recent call last):
  File "train.py", line 247, in <module>
    for data_dict, _ in dataloader_train:
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/nitin/anaconda3/envs/latent_face/lib/python3.8/site-packages/torch/utils/data/dataset.py", line 257, in __getitem__
    return self.dataset[self.indices[idx]]
  File "/home/nitin/latent-pose-reenactment/dataloaders/voxceleb2_segmentation_nolandmarks.py", line 196, in __getitem__
    dec_dicts = [self.loader.load_sample(path, i, self.imsize, **features_to_load) for i in dec_ids]
  File "/home/nitin/latent-pose-reenactment/dataloaders/voxceleb2_segmentation_nolandmarks.py", line 196, in <listcomp>
    dec_dicts = [self.loader.load_sample(path, i, self.imsize, **features_to_load) for i in dec_ids]
  File "/home/nitin/latent-pose-reenactment/dataloaders/voxceleb2_segmentation_nolandmarks.py", line 157, in load_sample
    segmentation = self.load_segm(path, i)
  File "/home/nitin/latent-pose-reenactment/dataloaders/voxceleb2_segmentation_nolandmarks.py", line 85, in load_segm
    raise FileNotFoundError(f'Sample {segm_path} not found')
FileNotFoundError: Sample DATASET_ROOT/segmentation-cropped/personA/00657.png not found

Where contents of folder IDENTITY_NAME be like:

(latent_face) nitin@nitin-desktop:~/latent-pose-reenactment/DATASET_ROOT/images-cropped/personA$ ls
00000.jpg  00092.jpg  00184.jpg  00276.jpg  00368.jpg  00460.jpg  00552.jpg  00644.jpg  00736.jpg  00828.jpg  00920.jpg  01012.jpg  01104.jpg 00001.jpg  00093.jpg  00185.jpg  00277.jpg  00369.jpg  00461.jpg  00553.jpg  00645.jpg  00737.jpg  00829.jpg  00921.jpg  01013.jpg  01105.jpg 00002.jpg  00094.jpg  00186.jpg  00278.jpg  00370.jpg  00462.jpg  00554.jpg  00646.jpg  00738.jpg  00830.jpg  00922.jpg  01014.jpg  01106.jpg

What I have observed is, when inside the folder IDENTITY_NAME the image are of extension *.jpg* then the code is looking for images of type .png** and vice versa.

I request you to please help me in solving this.

shrubb commented 3 years ago

You're showing contents for the wrong folder. The error is referring to segmentation maps, not to images.