This package helps extract i3D features with ResNet-50 backbone given a folder of videos
Project description
Hello, I am Hao Vy Phan. I have develop this package using ResNet-50 to convert a video into an extracted i3D features numpy file.
Update in this version: The function can receive directly the path to just 1 video, if multiplefiles is set False.
Overview
Input: a directory which store 1 or more videos.
Output: 1 or many .npy files (extracted i3D features). Each features file is shaped n/16 * 2048 where n is the number of frames in the video
If there is a problem installing or implementing this package, please do not hesitate to contact me via my email. I am pleased to have people use my product.
Usage
Installation
Before installing my package, please install these pakages: * Opencv-Python==4.5.5
* Or find your own python OS version of torch from this link: https://download.pytorch.org/whl/cu113/torch_stable.html
Installing them through pip install may raise errors. You can download the wheel files from the above links and run this code:
pip install torchvision-0.11.2+cu113-cp38-cp38-win_amd64.whl
pip install torchaudio-0.10.1+cu113-cp38-cp38-win_amd64.whl
pip install torch-1.10.1+cu113-cp38-cp38-win_amd64.whl
pip install opencv_python-4.5.5-cp38-cp38-win_amd64.whl
After 4 above packages, to install i3dFeatureExtraction package into your Python environment, run this code on your terminal:
pip install i3dFeatureExtraction
Implementing
The main function of this package is FeatureExtraction which converts a directory of videos into numpy feature files.
from i3dFeatureExtraction import FeatureExtraction
FeatureExtraction.generate(
datasetpath="directory/of/input/videos",
outputpath = "directory/to/store/output/numpy/files",
pretrainedpath = "path/to/i3D/pretrained/weight",
sample_mode = "oversample/center_crop"
multiplefiles = True/False
)
datasetpath (REQUIRED): path to videos.
If multiplefiles is True (default), the datasetpath is the path to a directory which contains 1 or more videos.
If multiplefiles is False, the datasetpath is the path to a video.
outputpath (optional, default: “output/”): the proccessed numpy feature files would be stored in this directory.
pretrainedpath (optional, default: “pretrained/”): the path of the pretrained i3d weight. If the weight is not existed, it will be downloaded and created manually.
sample_mode (optional, default: “oversample/”) receive “oversample” or “center_crop”. If oversample, each frame will be cropped and flipped to be turned into 10 frames.
Structure of this package
I am not good at drawing UML diagram but I hope this image helps illustrate the package’s structure.
Credits
This code is based on the following repositories:
* pytorch-i3d-feature-extraction
* E2E-Action-Segmentation/feature_extraction/
I would like to extend a special thank-you to the original authors of these repositories for providing the foundation on which this implementation is built.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for i3dFeatureExtraction-0.3.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d82148afbdc7eb94bdaa907ad95edf5741a9ae40332c4aa24a73432ffd4cebb6 |
|
MD5 | 574842a4031a37b9230ab32356880aa1 |
|
BLAKE2b-256 | dd3e7cad81b2d1da10a16d22c82b438a37a87d60465329b1dceb941c7c23b28c |
Hashes for i3dFeatureExtraction-0.3.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc0d79566657b10b5c5f1401d6e85ad4678a09334426505ef702deede9e7b07 |
|
MD5 | b68877157fe08ba39493f746870178c5 |
|
BLAKE2b-256 | 8b197e39f009e7e6a86909b2d1d7170dc2b26521afe3b58ffb101d7a62cc2d7c |