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

Simplify video_domain_adapter #292

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7ccd345
update .gitignore
xianyuanliu Jan 20, 2022
d955f73
update .gitignore
xianyuanliu Jan 20, 2022
1cecdf2
change root dir
xianyuanliu Jan 22, 2022
f9d0577
add EPIC100DatasetAccess
xianyuanliu Jan 22, 2022
046ef98
change transform_kind to transform
xianyuanliu Jan 22, 2022
77f1b0f
add NUM_SEGMENTS
xianyuanliu Jan 22, 2022
8a8581b
add INPUT_TYPE
xianyuanliu Jan 22, 2022
23b0e8e
add functions in VideoDatasetAccess for feature vector input
xianyuanliu Jan 22, 2022
f993f8d
add get_class_type
xianyuanliu Jan 22, 2022
60951d4
add CLASS_TYPE
xianyuanliu Jan 22, 2022
76f3e72
change num_classes to dict_num_classes
xianyuanliu Jan 22, 2022
feaf72a
update ClassNetVideo for dual-class task
xianyuanliu Jan 22, 2022
f5bc2b7
update test
xianyuanliu Jan 22, 2022
63c5be9
Merge branch 'main' into add_feature_vector_dataloader
xianyuanliu Jan 22, 2022
f89d8fc
change output folder to tb_logs
xianyuanliu Jan 22, 2022
b845a88
add get_class_type test
xianyuanliu Jan 22, 2022
ef74b72
update test_video_access
xianyuanliu Jan 22, 2022
b43802c
update config
xianyuanliu Jan 22, 2022
ba6f5c5
test bug fixes
xianyuanliu Jan 23, 2022
bdf9cbb
add VideoFeatureRecord in Videos.py & improve doc
xianyuanliu Jan 23, 2022
3ea4678
add epic100 test & bug fixes
xianyuanliu Jan 23, 2022
1540051
test bug fixes
xianyuanliu Jan 23, 2022
de0e6cd
test bug fixes
xianyuanliu Jan 23, 2022
cf1638b
add BaseAdaptTrainerVideo
xianyuanliu Jan 23, 2022
a2b3ce8
bug fixes
xianyuanliu Jan 23, 2022
4470413
add CLASS_TYPE
xianyuanliu Jan 23, 2022
37aeaac
add conditional function for class type
xianyuanliu Jan 23, 2022
a95a185
rename to num_classes
xianyuanliu Feb 7, 2022
ab23896
change root dir
xianyuanliu Feb 7, 2022
40861fc
Update doc
xianyuanliu Feb 7, 2022
dc4b990
Merge branch 'add_feature_vector_dataloader' into simplify_video_doma…
xianyuanliu Feb 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add EPIC100DatasetAccess
  • Loading branch information
xianyuanliu committed Jan 22, 2022
commit f9d057741ab5ff2e833c066c66394ca76d5e904f
78 changes: 77 additions & 1 deletion kale/loaddata/video_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import os
from copy import deepcopy
from enum import Enum
from pathlib import Path

import pandas as pd
import torch

import kale.prepdata.video_transform as video_transform
from kale.loaddata.dataset_access import DatasetAccess
from kale.loaddata.video_datasets import BasicVideoDataset, EPIC
from kale.loaddata.videos import VideoFrameDataset


def get_image_modality(image_modality):
Expand Down Expand Up @@ -213,13 +216,14 @@ class VideoDatasetAccess(DatasetAccess):
"""

def __init__(
self, data_path, train_list, test_list, image_modality, frames_per_segment, n_classes, transform_kind, seed
self, data_path, train_list, test_list, image_modality, num_segments, frames_per_segment, n_classes, transform_kind, seed
):
super().__init__(n_classes)
self._data_path = data_path
self._train_list = train_list
self._test_list = test_list
self._image_modality = image_modality
self._num_segments = num_segments
self._frames_per_segment = frames_per_segment
self._transform = video_transform.get_transform(transform_kind, self._image_modality)
self._seed = seed
Expand Down Expand Up @@ -370,3 +374,75 @@ def get_test(self):
dataset_split="test",
n_classes=self._n_classes,
)


class EPIC100DatasetAccess(VideoDatasetAccess):
"""EPIC-100 video feature data loader"""

def __init__(
self,
domain,
data_path,
train_list,
test_list,
image_modality,
num_segments,
frames_per_segment,
n_classes,
transform,
seed,
input_type,
):
super(EPIC100DatasetAccess, self).__init__(
data_path,
train_list,
test_list,
image_modality,
num_segments,
frames_per_segment,
n_classes,
transform,
seed,
)
self._input_type = input_type
self._domain = domain
self._num_train_dataload = len(pd.read_pickle(self._train_list).index)
self._num_test_dataload = len(pd.read_pickle(self._test_list).index)

def get_train(self):
return VideoFrameDataset(
root_path=Path(self._data_path, self._input_type, "{}_val.pkl".format(self._domain)),
# Uncomment to run on train subset for EPIC 2021 challenge
# data_path=Path(self._data_path, self._input_type, "{}_train.pkl".format(self._domain)),
annotationfile_path=self._train_list,
total_segments=25,
num_segments=self._num_segments, # 1
frames_per_segment=self._frames_per_segment, # 1
image_modality=self._image_modality,
imagefile_template="img_{:05d}.t7"
if self._image_modality in ["RGB", "RGBDiff", "RGBDiff2", "RGBDiffplus"]
else self._input_type + "{}_{:05d}.t7",
random_shift=False,
test_mode=True,
input_type="feature",
num_data_load=self._num_train_dataload,
)

def get_test(self):
return VideoFrameDataset(
root_path=Path(self._data_path, self._input_type, "{}_val.pkl".format(self._domain)),
# Uncomment to run on test subset for EPIC 2021 challenge
# data_path=Path(self._data_path, self._input_type, "{}_test.pkl".format(self._domain)),
annotationfile_path=self._test_list,
total_segments=25,
num_segments=self._num_segments,
frames_per_segment=self._frames_per_segment,
image_modality=self._image_modality,
imagefile_template="img_{:05d}.t7"
if self._image_modality in ["RGB", "RGBDiff", "RGBDiff2", "RGBDiffplus"]
else self._input_type + "{}_{:05d}.t7",
random_shift=True,
test_mode=True,
input_type="feature",
num_data_load=self._num_test_dataload,
)