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

Conversation

xianyuanliu
Copy link
Member

@xianyuanliu xianyuanliu commented Jan 23, 2022

Description

Improve video_domain_adapter.py via organizing repeated and redundant codes into BaseAdaptTrainerVideo. This PR follows PR #291 and is followed by a large PR that will merge feature vector into action_dann_lightn example.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • In-line docstrings updated.
  • Source for documentation at docs manually updated for new API.

@xianyuanliu xianyuanliu added enhancement Improvement of existing code work-in-progress Work in progress that should NOT be merged labels Jan 23, 2022
@github-actions github-actions bot added this to In progress in v0.1.0 Jan 23, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2022

Codecov Report

Merging #292 (dc4b990) into main (e42b4ec) will decrease coverage by 1.88%.
The diff coverage is 80.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
- Coverage   92.98%   91.10%   -1.89%     
==========================================
  Files          45       45              
  Lines        4635     4790     +155     
==========================================
+ Hits         4310     4364      +54     
- Misses        325      426     +101     
Impacted Files Coverage Δ
kale/loaddata/video_datasets.py 86.44% <ø> (ø)
kale/pipeline/domain_adapter.py 94.27% <ø> (+0.19%) ⬆️
kale/loaddata/videos.py 74.48% <53.57%> (-12.89%) ⬇️
kale/pipeline/video_domain_adapter.py 80.13% <81.52%> (-16.81%) ⬇️
kale/loaddata/video_access.py 97.05% <94.91%> (-0.86%) ⬇️
kale/embed/video_feature_extractor.py 96.66% <100.00%> (+0.05%) ⬆️
kale/predict/class_domain_nets.py 91.89% <100.00%> (+1.89%) ⬆️
kale/prepdata/video_transform.py 88.00% <100.00%> (+1.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e42b4ec...dc4b990. Read the comment docs.

@xianyuanliu xianyuanliu removed the work-in-progress Work in progress that should NOT be merged label Jan 24, 2022
@xianyuanliu xianyuanliu marked this pull request as ready for review January 29, 2022 04:23
@@ -16,15 +16,17 @@
# Dataset
# -----------------------------------------------------------------------------
_C.DATASET = CN()
_C.DATASET.ROOT = "I:/Datasets/EgoAction/" # "/shared/tale2/Shared"
_C.DATASET.ROOT = "J:/Datasets/EgoAction/" # "/shared/tale2/Shared"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as in PR #291.

@@ -96,41 +126,47 @@ class VideoFrameDataset(torch.utils.data.Dataset):
might be ``jumping\0052\`` or ``sample1\`` or ``00053\``.

Args:
root_path: The root path in which video folders lie.
root_path (str, Path): root path in which video folders lie.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Path a Python variable type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to pathlib.Path.

this is ROOT_DATA from the description above.
annotationfile_path: The .txt annotation file containing
annotationfile_path (str, Path): .txt annotation file containing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

have inside of their video folders as described above.
transform: Transform pipeline that receives a list of PIL images/frames.
random_shift: Whether the frames from each segment should be taken
transform (Compose, optional): transform pipeline that receives a list of PIL images/frames.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torchvision.transforms.Compose

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

image_modality (str): image modality (RGB or Optical Flow).
num_segments (int): number of segments the video should be divided into to sample frames from.
Default is 1 in image mode and 5 in feature vector mode.
frames_per_segment (int): number of frames that should
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines seem do not exceed 120 characters. Please check the same problems for the other.

"""
Builds and returns a model and associated hyper parameters according to the config object passed.

Args:
cfg: A YACS config object.
dataset: A multi domain dataset consisting of source and target datasets.
num_classes: The class number of specific dataset.
dict_num_classes (dict): The dictionary of class number for specific dataset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to implement this as a class (e.g., https://github.com/pykale/pykale/blob/main/kale/pipeline/domain_adapter.py#L81). We can discuss if you need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function returning boolean variables is used to control image_modality and class_type. A class may be a better choice, but I have no idea about this. We can talk.

n_verb_channel=256,
n_noun_channel=512,
dropout_keep_prob=0.5,
class_type="verb",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comments above, we can implement the a class for the type of classes.

@haipinglu haipinglu removed this from In progress in v0.1.0 Aug 11, 2022
@haipinglu haipinglu added this to In progress in v0.2.0 via automation Aug 11, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

This pull request has been automatically marked as stale due to lack of activity.

@github-actions github-actions bot added the Stale label Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing code Stale
Projects
Status: In progress
v0.2.0
In progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants