logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 1 year ago

action-classification

Video Classification with MoViNet

Author: Xinyu Ge


Description

A video classification operator generates labels (and corresponding scores) and extracts features for the input video. It transforms the video into frames and loads pre-trained models by model names. This operator has implemented pre-trained models from MoViNet and maps vectors with labels provided by datasets used for pre-training.


Code Example

Use the pretrained Movinet model to classify and generate a vector for the given video path './jumpingjack.gif' (download).

Write a pipeline with explicit inputs/outputs name specifications:

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('path')
        .map('path', 'frames', ops.video_decode.ffmpeg())
        .map('frames', ('labels', 'scores', 'features'),
             ops.action_classification.movinet(model_name='movineta0'))
        .output('path', 'labels', 'scores', 'features')
)

DataCollection(p('./jumpingjack.gif')).show()


Factory Constructor

Create the operator via the following factory method

video_classification.movinet( model_name='movineta0', skip_preprocess=False, classmap=None, topk=5)

Parameters:

model_name: str

​ The name of pre-trained MoViNet model.

​ Supported model names:

  • movineta0
  • movineta1
  • movineta2
  • movineta3
  • movineta4
  • movineta5

skip_preprocess: bool

​ Flag to control whether to skip video transforms, defaults to False. If set to True, the step to transform videos will be skipped. In this case, the user should guarantee that all the input video frames are already reprocessed properly, and thus can be fed to model directly.

classmap: Dict[str: int]:

​ Dictionary that maps class names to one hot vectors. If not given, the operator will load the default class map dictionary.

topk: int

​ The topk labels & scores to present in result. The default value is 5.

Interface

A video classification operator generates a list of class labels and a corresponding vector in numpy.ndarray given a video input data.

Parameters:

video: Union[str, numpy.ndarray]

​ Input video data using local path in string or video frames in ndarray.

Returns: (list, list, torch.Tensor)

​ A tuple of (labels, scores, features), which contains lists of predicted class names and corresponding scores.

Jael Gu f0ead162f3 Remove dc2 16 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 2 years ago
file-icon README.md
2.6 KiB
download-icon
Remove dc2 1 year ago
file-icon __init__.py
675 B
download-icon
add movinet 2 years ago
file-icon kinetics_600.csv
11 KiB
download-icon
add movinet 2 years ago
file-icon movinet.py
4.1 KiB
download-icon
modify features 2 years ago
file-icon requirements.txt
66 B
download-icon
update 2 years ago
file-icon result.png
16 KiB
download-icon
Update 1 year ago