Commit 1075c8a5 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

[VideoToFrames] pass annotations too

parent a096a142
Pipeline #45574 failed with stage
in 5 minutes and 11 seconds
from sklearn.base import TransformerMixin, BaseEstimator
import bob.pipelines as mario
from bob.pipelines.wrappers import _frmt
import logging
logger = logging.getLogger(__name__)
class VideoToFrames(TransformerMixin, BaseEstimator):
"""Expands frame containers to frame-based samples only when transform is called.
When fit_transform is called, it just converts frame containers to numpy arrays.
"""Expands video samples to frame-based samples only when transform is called.
"""
def transform(self, video_samples):
logger.info(
f"Calling {self.__class__.__name__}.transform from VideoToFrames"
)
logger.debug(f"{_frmt(self)}.transform")
output = []
for sample in video_samples:
for frame, frame_id in zip(sample.data, sample.data.indices):
new_sample = mario.Sample(frame, frame_id=frame_id, parent=sample)
annotations = getattr(sample, "annotations", {})
for frame, frame_id in zip(sample.data.data, sample.data.indices):
new_sample = mario.Sample(
frame,
frame_id=frame_id,
annotations=annotations.get(str(frame_id)),
parent=sample,
)
output.append(new_sample)
return output
def fit(self, X, y=None, **fit_params):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment