niyunsheng/CORE

About Learning at Celeb-DF

Closed this issue · 5 comments

What code do you use to cut out frames when learning in Celeb-DF?
If it is not in this repository, we would appreciate it if you could upload it.
Also, what is the directory structure at that time?

Code of preprocessing Celeb-DF:

  • For each video in Celeb-DF, we extract 3 frames per second. We crop the faces with bounding boxes (detected boxes enlarged 1.3×) which is provided by MTCNN. See Section 4.2. Implementation Details for more details.
  • You can deal with this problem by slightly modifying the published code prep_w_mask.py.

The directory structure of video frames remains the same as video.

Thank you very much.
However, I have a new problem.

python main.py --dataset celebdf --aug-name RE --consistency cos --consistency-rate 1.0

When I run the above, I get the following error
When outputting img_path and label in base_dataset.py, "/" and "m" are output.
What is the cause?

args: Namespace(amp=False, aug_name='RE', batch_size=32, consistency='cos', consistency_rate=1.0, dataset='celebdf', epochs=30, exp_name='test', ff_quality='c23', gpus='0', load_model_path=None, log_interval=100, lr=0.0002, model_name='xception', norm='0.5', num_classes=2, num_workers=8, optimizer='adam', real_weight=4.0, root='/media/tr22008/hdd/celeb_core/', seed=3407, shuffle=True, size=299) train aug:<transform.TwoTransform object at 0x7fd7f35f0f60> test aug:Compose( Resize(size=299, interpolation=bilinear, max_size=None, antialias=None) RandomHorizontalFlip(p=0.5) ToTensor() Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]) ) csv path: /media/tr22008/hdd/celeb_core/List_of_testing_videos.txt [train] fake imgs count :23437, real imgs count :12113 csv path: /media/tr22008/hdd/celeb_core/List_of_testing_videos.txt [test] fake imgs count :1770, real imgs count :1120 len train dataset:35550 len test dataset:2890 consistency loss function: ConsistencyCos( (mse_fn): MSELoss() ), rate:1.0 optimizer: Adam ( Parameter Group 0 amsgrad: False betas: (0.9, 0.999) eps: 1e-08 lr: 0.0002 weight_decay: 0 ) img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / label: m img path: / img path: / label: m label: m img path: / label: m img path: / label: m img path: / img path: / label: m label: m Traceback (most recent call last): File "main.py", line 196, in <module> main(args) File "main.py", line 144, in main trainer.train_epoch(epoch_idx) File "/home/tr22008/deepfake_detection/CORE-main/src/trainer.py", line 56, in train_epoch for batch_idx,(data,label) in enumerate(self.train_loader): File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 521, in __next__ data = self._next_data() File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data return self._process_data(data) File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data data.reraise() File "/home/tr22008/.local/lib/python3.6/site-packages/torch/_utils.py", line 425, in reraise raise self.exc_type(msg) IsADirectoryError: Caught IsADirectoryError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/tr22008/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/tr22008/deepfake_detection/CORE-main/src/datasets/base_dataset.py", line 18, in __getitem__ image = Image.open(img_path).convert('RGB') File "/home/tr22008/.local/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open fp = builtins.open(filename, "rb") IsADirectoryError: [Errno 21] Is a directory: '/'

I think the img_path may be not correct, you can print the img_path in the dataset and debug.

I checked the path as print('imgs:',self.imgs) in def __getitem__(self,idx) in base_dataset.py and it is not wrong.
I rewrote self.imgs = [[p,1] for p in fake_imgs] + [[p,0] for p in real_imgs] in celeb_df.py as follows and it worked.
What is the cause?
IMG

Yeah, you are right.
I will fix this.