cvlab-yonsei / MNAD

An official implementation of "Learning Memory-guided Normality for Anomaly Detection" (CVPR 2020) in PyTorch.
333 stars 82 forks source link

The downloaded shanghaitech dataset is a video. How to convert it into a frame? Or can you put a download link to the Shanghai dataset? #29

Open xiximin opened 3 years ago

saypadith commented 3 years ago

Using FFmpeg Please refer to this: https://superuser.com/a/1346333

william-yl-gu commented 3 years ago

Just curious, do you set the fps during the conversion?

saypadith commented 3 years ago

Just curious, do you set the fps during the conversion?

This is my code: I set it to 24fps (-r 24/1) as it shows in the detail of the video.

for %%F in (*.avi) do (
    If not Exist "%%~nF" MkDir "%%~nF"
    ffmpeg -i %%F -r 24/1 -qscale:v 2 %%~nF\%%~nF-%%3d.jpg
)
xiximin commented 3 years ago

Thank you. I'll try.

xiximin commented 3 years ago

An error occurred while training the Shanghai dataset. Traceback (most recent call last): File "Train.py", line 154, in for j,(imgs) in enumerate(train_batch): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 1. Original Traceback (most recent call last): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/root/userfolder/software/anaconda3/envs/MemG/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 "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/userfolder/code/projects1/MNAD/FFPMem/model/utils.py", line 71, in getitem image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width) IndexError: list index out of range

TanMing11 commented 3 years ago

Just curious, do you set the fps during the conversion?

This is my code: I set it to 24fps (-r 24/1) as it shows in the detail of the video.

for %%F in (*.avi) do (
    If not Exist "%%~nF" MkDir "%%~nF"
    ffmpeg -i %%F -r 24/1 -qscale:v 2 %%~nF\%%~nF-%%3d.jpg
)

hello,could you tell me how to use this code?

yangyangtiaoguo commented 3 years ago

An error occurred while training the Shanghai dataset. Traceback (most recent call last): File "Train.py", line 154, in for j,(imgs) in enumerate(train_batch): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 1. Original Traceback (most recent call last): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/root/userfolder/software/anaconda3/envs/MemG/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 "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/userfolder/code/projects1/MNAD/FFPMem/model/utils.py", line 71, in getitem image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width) IndexError: list index out of range

An error occurred while training the Shanghai dataset. Traceback (most recent call last): File "Train.py", line 154, in for j,(imgs) in enumerate(train_batch): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 1. Original Traceback (most recent call last): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/root/userfolder/software/anaconda3/envs/MemG/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 "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/userfolder/code/projects1/MNAD/FFPMem/model/utils.py", line 71, in getitem image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width) IndexError: list index out of range

Hello, I also encountered this problem, how did you solve it? Thanks!

TanMing11 commented 3 years ago

An error occurred while training the Shanghai dataset. Traceback (most recent call last): File "Train.py", line 154, in for j,(imgs) in enumerate(train_batch): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 1. Original Traceback (most recent call last): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/root/userfolder/software/anaconda3/envs/MemG/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 "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/userfolder/code/projects1/MNAD/FFPMem/model/utils.py", line 71, in getitem image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width) IndexError: list index out of range

An error occurred while training the Shanghai dataset. Traceback (most recent call last): File "Train.py", line 154, in for j,(imgs) in enumerate(train_batch): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in next return self._process_data(data) File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data data.reraise() File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 1. Original Traceback (most recent call last): File "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/root/userfolder/software/anaconda3/envs/MemG/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 "/root/userfolder/software/anaconda3/envs/MemG/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/userfolder/code/projects1/MNAD/FFPMem/model/utils.py", line 71, in getitem image = np_load_frame(self.videos[video_name]['frame'][frame_name+i], self._resize_height, self._resize_width) IndexError: list index out of range

Hello, I also encountered this problem, how did you solve it? Thanks!

hello,did you solve it?