Skip to content
Snippets Groups Projects
Commit fc98ae01 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[advanced][databases][livdet-iris-2020] Add new version following V2 implementation

parent d229f149
No related branches found
No related tags found
1 merge request!28Add protocoltemplates
{
"description": "LivDet Iris 2020 test database",
"environment": {
"name": "Example databases",
"version": "1.4.1"
},
"protocols": [
{
"name": "Main",
"template": "iris_pad/1",
"views": {
"test": {
"view": "Test",
"parameters": {}
}
}
}
],
"root_folder": "/somewhere",
"schema_version": 2
}
\ No newline at end of file
import os
import numpy as np
import pandas as pd
from beat.backend.python.database import View
from PIL import Image
class Test(View):
def index(self, root_folder, parameters):
"""Creates the data for the database indexation"""
csv_path = os.path.join(root_folder, "test.csv")
df = pd.read_csv(csv_path)
df["filename"] = df["filename"].apply(lambda x: os.path.join(root_folder, x))
df = df.rename(columns={"filename": "image"})
# ------------- v1 random labels -----
# remove this part for v2 release
num_files = len(df)
np.random.seed(0)
df["label"] = np.random.randint(0, 2, size=num_files, dtype=bool)
df["category"] = np.random.randint(1, 7, size=num_files, dtype=int)
# ------------------------------------
return list(df.itertuples(index=False))
def get(self, output, index):
"""Returns the data for the output based on the index content"""
obj = self.objs[index]
if output == "image":
img = np.asarray(Image.open(obj.image))
return {"value": img}
elif output == "label":
return {"value": bool(obj.label)}
elif output == "category":
return {"value": np.cast["int32"](obj.category)}
LivDet Iris 2020 test database
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment