Giter VIP home page Giter VIP logo

vdataset's Introduction

vdataset

python pytorch

Description

Load video datasets to PyTorch DataLoader. (Custom Video Data set for PyTorch DataLoader)
VDataset can be use to load 20BN-Jester dataset to the PyTorch DataLoader

Required Libraries

  • torch
  • Pillow
  • pandas

Arguments

LableMap Constructor

Argument Type Required Default Description
labels_csv str False None The path to the csv file containing the labels and ids.
labels_col_name str False None The name of the column containing the labels. (Required if labels_csv is not None)
ids_col_name str/ None False None The name of the column containing the ids.
id_type type False int The type of the ids.

VDataset Constructor

Argument Type Required Default Description
csv_file str True - Path to .csv file
root_dir str True - Root Directory of the video dataset
file_format str False jpg File type of the frame images (ex: .jpg, .jpeg, .png)
id_col_name str False video_id Column name, where id/name of the video on the .csv file
label_col_name str False label Column name, where label is on the .csv file
frames_limit_mode str/None False None Mode of the frame count detection ("manual", "csv" or else it auto detects all the frames available)
frames_limit dict False {"start": 0, "end": None} Number of frames in a video (required if frames_count_mode set to "manual")
frames_limit_col_name str False frames Column name, where label is on the .csv file (required if frames_count_mode set to "csv")
video_transforms tuple/None False None Video Transforms (Refer: https://github.com/hassony2/torch_videovision)
label_map LabelMap/None False None Label Map of the Dataset

Usage

from vdataset import LabelMap, VDataset

from torch.utils.data import DataLoader

from torchvideotransforms.volume_transforms import ClipToTensor # https://github.com/hassony2/torch_videovision
from torchvideotransforms import video_transforms, volume_transforms # https://github.com/hassony2/torch_videovision

# Create Label Map
label_map = LabelMap(labels_csv="/path-to-csv/csv_file.csv", labels_col_name="label") 

print(label_map)
label_map.print() # printing the labels on label-map

# Use Video Transformers
video_transform_list = [video_transforms.RandomRotation(30),
            video_transforms.Resize((100, 100)),
            volume_transforms.ClipToTensor()]
video_transforms = video_transforms.Compose(video_transform_list)

# Create Vdataset (No frame limitation)
full_dataset = VDataset(csv_file='/path-to-csv/csv_file.csv', root_dir='/path-to-root/', video_transforms=video_transforms, label_map=label_map)

# Create Vdataset (Manual frames limitation, remove first 5 frames and last 5 frames)
frames_limited_dataset = VDataset(csv_file='/path-to-csv/csv_file.csv', root_dir='/path-to-root/', video_transforms=video_transforms, frames_limit_mode="manual",  frames_limit={"start": 5, "end": -5} label_map=label_map)

full_dataloader = DataLoader(full_dataset, batch_size=64, shuffle=True, num_workers=2, pin_memory=True)
print(full_dataloader)

frames_limited_dataloader = DataLoader(frames_limited_dataset, batch_size=64, shuffle=True, num_workers=2, pin_memory=True)
print(frames_limited_dataloader)

for image, label in full_dataloader: # Do what do you want in dataset
    print(image, label)
    print(image.size())
    break

for image, label in frames_limited_dataloader: # Do what do you want in dataset
    print(image, label)
    print(image.size())
    break

vdataset's People

Contributors

nzx9 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.