Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.pad.face
Commits
1075c8a5
Commit
1075c8a5
authored
Nov 13, 2020
by
Amir MOHAMMADI
Browse files
[VideoToFrames] pass annotations too
parent
a096a142
Pipeline
#45574
failed with stage
in 5 minutes and 11 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/pad/face/transformer/VideoToFrames.py
View file @
1075c8a5
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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment