Commit 9a3f8488 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

WIP: port databases to the new csv format

parent fb28b9f4
Pipeline #48602 failed with stage
in 10 minutes and 58 seconds
......@@ -13,7 +13,10 @@ else:
# Preprocessor #
cropper = face_crop_solver(
cropped_image_size=64, cropped_positions=annotation_type, color_channel="gray"
cropped_image_size=64,
cropped_positions=annotation_type,
color_channel="gray",
fixed_positions=fixed_positions,
)
preprocessor = VideoWrapper(cropper)
preprocessor = mario.wrap(
......
......@@ -13,6 +13,5 @@ the link.
.. include:: links.rst
"""
from bob.pad.face.database import ReplayMobilePadDatabase
from bob.pad.base.pipelines.vanilla_pad import DatabaseConnector
database = DatabaseConnector(ReplayMobilePadDatabase())
database = ReplayMobilePadDatabase()
from .database import VideoPadFile
from .database import VideoPadFile, VideoPadSample
from .replay import ReplayPadDatabase
from .replay_mobile import ReplayMobilePadDatabase
from .mifs import MIFSPadDatabase
......
from functools import partial
import os
from bob.pad.base.database import PadFile
import bob.bio.video
import bob.io.video
from bob.db.base.annotations import read_annotation_file
from sklearn.preprocessing import FunctionTransformer
from bob.bio.video import VideoAsArray
from bob.pipelines import DelayedSample
def delayed_video_load(
samples,
original_directory,
annotation_directory=None,
selection_style=None,
max_number_of_frames=None,
step_size=None,
get_transform=None,
):
if get_transform is None:
def get_transform(x):
return None
original_directory = original_directory or ""
annotation_directory = annotation_directory or ""
results = []
for sample in samples:
video_path = os.path.join(original_directory, sample.filename)
data = partial(
VideoAsArray,
path=video_path,
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
step_size=step_size,
transform=get_transform(sample),
)
annotations, delayed_attributes = None, None
if annotation_directory:
path = os.path.splitext(sample.filename)[0]
delayed_annotations = partial(
read_annotation_file,
file_name=f"{annotation_directory}:{path}.json",
annotation_type="json",
)
delayed_attributes = {"annotations": delayed_annotations}
results.append(
DelayedSample(
data,
parent=sample,
delayed_attributes=delayed_attributes,
annotations=annotations,
)
)
return results
def VideoPadSample(
original_directory,
annotation_directory=None,
selection_style=None,
max_number_of_frames=None,
step_size=None,
get_transform=None,
):
return FunctionTransformer(
delayed_video_load,
validate=False,
kw_args=dict(
original_directory=original_directory,
annotation_directory=annotation_directory,
selection_style=selection_style,
max_number_of_frames=max_number_of_frames,
step_size=step_size,
get_transform=get_transform,
),
)
class VideoPadFile(PadFile):
......
This diff is collapsed.
This diff is collapsed.
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