Sense-X/UniFormer

[Question for Video Classification] Registering my custom dataset

Closed this issue · 4 comments

Hi, I'm back again with another issue :).

My goal is to finetune the UniFormer to my custom video dataset.
For this, I need to prepare a proper Pytorch dataset class like in slowfast/datasets/kinetics.py first. But, I met a registry issue for my dataset.
image

I followed issue #149 in FAIR's slowfast github, but in my case, since I prepared my dataset in Kinetics-400 format, duplicated and retouched kinetics.py.

I'm wasting much time solving this :s ... but, I have no idea which point I missed.

My process is as below.


Step1. Copy kinetics.py and Rename it into my custom dataset

For example, suppose my dataset name is Boho, I change 1) the python script name and 2) the class name

  • kinetics.pyboho.py.
  • Class Kinetics(...)Class Boho(...)

logger = logging.get_logger(__name__)
@DATASET_REGISTRY.register()
class Kinetics(torch.utils.data.Dataset):
"""
Kinetics video loader. Construct the Kinetics video loader, then sample
clips from the videos. For training and validation, a single clip is
randomly sampled from every video with random cropping, scaling, and
flipping. For testing, multiple clips are uniformaly sampled from every
video with uniform cropping. For uniform cropping, we take the left, center,
and right crop if the width is larger than height, or take top, center, and
bottom crop if the height is larger than the width.
"""

image

Step2. Adding the line from .boho import Boho to the __init__.py file in the same folder.

from .ava_dataset import Ava # noqa
from .build import DATASET_REGISTRY, build_dataset # noqa
from .charades import Charades # noqa
from .imagenet import Imagenet # noqa
from .kinetics import Kinetics # noqa
from .ptv_datasets import Ptvcharades, Ptvkinetics, Ptvssv2 # noqa
from .sth import Sth # noqa

image

Step3. Rebuild the slowfast package

~$ python setup.py build develop

Step4. Assign TRAIN.DATASET = 'boho' in config.yaml

image


I learned that the decorator @DATASET_REGISTRY.register() is to register my data object into fvcore Registry, but still is not yet.

Can you give me feedback on which part I missed?

I believe you have followed the right steps since I also register datasets like you here.

You can try to print the dataset names via the followed codes and check the bug...

print(DATASET_REGISTRY)

Actually, the step3 can be ignored. The repo does not need to be rebuilt.

Okay, I found out the problem. That was related to the python path issue.
I duplicated another slowfast project and the dataset registry scoped that workspace where there is not my custom dataset.
After making it ignoring that path, everything works well :) thank.

By the way, you are doing another interesting project. I would also check it later!

Thanks for your sharing

Thanks for your reply. Don't forget to add PYTHONPATH when running your experiment.

PYTHONPATH=$PYTHONPATH:./slowfast \

Hi, i have same problem, please, help me @DoranLyong.

These step I have done.

1 Create file: MyDataset.py, copy from Kinetics.py
2 add this in init.py

from .custom_data import MyDataset

3 edit in config.yaml

and this is architecture data

  DATASET: mydataset

mydataset
-a01
-a02
-a03
-a04
-a05
-a06
-a07
-a08
-a09
-a10
-train.csv
-test.csv
-val.csv