diff --git a/advanced/databases/livdet-iris-2020/2.json b/advanced/databases/livdet-iris-2020/2.json new file mode 100644 index 0000000000000000000000000000000000000000..76bb6dd1c9d65db73bd422df36a913538881c1b1 --- /dev/null +++ b/advanced/databases/livdet-iris-2020/2.json @@ -0,0 +1,21 @@ +{ + "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 diff --git a/advanced/databases/livdet-iris-2020/2.py b/advanced/databases/livdet-iris-2020/2.py new file mode 100644 index 0000000000000000000000000000000000000000..f8460135a13ed794bdfcbd6f1fb9685b75395424 --- /dev/null +++ b/advanced/databases/livdet-iris-2020/2.py @@ -0,0 +1,40 @@ +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)} diff --git a/advanced/databases/livdet-iris-2020/2.rst b/advanced/databases/livdet-iris-2020/2.rst new file mode 100644 index 0000000000000000000000000000000000000000..298357be0097371aa47a386a185199cfb7abcfe1 --- /dev/null +++ b/advanced/databases/livdet-iris-2020/2.rst @@ -0,0 +1 @@ +LivDet Iris 2020 test database \ No newline at end of file