From f44ba9d28aff064d49c28f8df7fda6babbf175c0 Mon Sep 17 00:00:00 2001 From: Rabah Khalek Date: Mon, 19 Aug 2024 12:03:04 +0200 Subject: [PATCH] Renaming classes (#57) * cleanup and refactoring of examples * refactoring models and datasets * refactoring detectors * added pillow dep * added scikit-learn dep * added pandas dep --- .../image_classification/load_datasets.ipynb | 211 --- examples/image_classification/sc_models.ipynb | 145 ++ examples/image_classification/sc_scan.ipynb | 41 + .../single_classification_models.ipynb | 481 ----- .../criterias/criteria1_partial_faces.ipynb | 2 +- .../landmark_detection/example_scan.ipynb | 1567 ----------------- examples/landmark_detection/example_scan.py | 15 - .../example_vision_opencv_300w_all.html | 594 ------- .../example_vision_opencv_300w_indoor.html | 527 ------ .../ffhq/ffhq-filtering-caching.ipynb | 2 +- .../ffhq/ffhq-filtering.ipynb | 2 +- examples/landmark_detection/ffhq/ffhq.ipynb | 2 +- examples/landmark_detection/ffhq_scan.ipynb | 41 + .../{ => datasets}/racoon_detection/.DS_Store | Bin .../racoon_detection/Racoon Images/.DS_Store | Bin .../Racoon Images/images/.DS_Store | Bin .../Racoon Images/images/raccoon-11.jpg | Bin .../Racoon Images/images/raccoon-124.jpg | Bin .../Racoon Images/images/raccoon-141.jpg | Bin .../Racoon Images/images/raccoon-17.jpg | Bin .../Racoon Images/images/raccoon-180.jpg | Bin .../Racoon Images/images/raccoon-19.jpg | Bin .../Racoon Images/images/raccoon-200.jpg | Bin .../Racoon Images/images/raccoon-60.jpg | Bin .../Racoon Images/images/raccoon-69.jpg | Bin .../Racoon Images/images/raccoon-84.jpg | Bin .../racoon_detection/train_labels_.csv | 0 examples/object_detection/ffhq_scan.ipynb | 45 + ...room_passes.ipynb => furniture_scan.ipynb} | 30 +- examples/object_detection/racoons.ipynb | 83 - examples/object_detection/racoons_scan.ipynb | 52 + .../test_face_detection.ipynb | 270 --- giskard_vision/__init__.py | 5 +- .../core/dataloaders/{tfds.py => tf.py} | 2 +- ..._blurring_detector.py => blur_detector.py} | 16 +- ...on_color_detector.py => color_detector.py} | 14 +- ..._scan_detector.py => metadata_detector.py} | 2 +- ...on_noise_detector.py => noise_detector.py} | 16 +- .../dataloaders/loaders.py | 10 +- .../detectors/__init__.py | 4 +- .../detectors/metadata_detector.py | 4 +- .../image_classification/models/base.py | 2 +- .../image_classification/models/wrappers.py | 12 +- .../landmark_detection/dataloaders/loaders.py | 4 +- .../landmark_detection/detectors/__init__.py | 12 +- ...{cropping_detector.py => crop_detector.py} | 4 +- .../detectors/metadata_detector.py | 6 +- ..._resize_detector.py => resize_detector.py} | 4 +- .../detectors/surrogate_functions.py | 2 +- .../object_detection/dataloaders/loaders.py | 4 +- .../object_detection/detectors/__init__.py | 4 +- .../detectors/metadata_detector.py | 4 +- .../detectors/surrogate_functions.py | 2 +- .../object_detection/models/wrappers.py | 6 +- pdm.lock | 428 +---- pyproject.toml | 5 +- tests/core/dataloaders/test_tfds.py | 4 +- .../detectors/test_detectors.py | 32 +- 58 files changed, 453 insertions(+), 4265 deletions(-) delete mode 100644 examples/image_classification/load_datasets.ipynb create mode 100644 examples/image_classification/sc_models.ipynb create mode 100644 examples/image_classification/sc_scan.ipynb delete mode 100644 examples/image_classification/single_classification_models.ipynb delete mode 100644 examples/landmark_detection/example_scan.ipynb delete mode 100644 examples/landmark_detection/example_scan.py delete mode 100644 examples/landmark_detection/example_vision_opencv_300w_all.html delete mode 100644 examples/landmark_detection/example_vision_opencv_300w_indoor.html create mode 100644 examples/landmark_detection/ffhq_scan.ipynb rename examples/object_detection/{ => datasets}/racoon_detection/.DS_Store (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/.DS_Store (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/.DS_Store (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-11.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-124.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-141.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-17.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-180.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-19.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-200.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-60.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-69.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/Racoon Images/images/raccoon-84.jpg (100%) rename examples/object_detection/{ => datasets}/racoon_detection/train_labels_.csv (100%) create mode 100644 examples/object_detection/ffhq_scan.ipynb rename examples/object_detection/{living_room_passes.ipynb => furniture_scan.ipynb} (67%) delete mode 100644 examples/object_detection/racoons.ipynb create mode 100644 examples/object_detection/racoons_scan.ipynb delete mode 100644 examples/object_detection/test_face_detection.ipynb rename giskard_vision/core/dataloaders/{tfds.py => tf.py} (98%) rename giskard_vision/core/detectors/{transformation_blurring_detector.py => blur_detector.py} (63%) rename giskard_vision/core/detectors/{transformation_color_detector.py => color_detector.py} (57%) rename giskard_vision/core/detectors/{metadata_scan_detector.py => metadata_detector.py} (99%) rename giskard_vision/core/detectors/{transformation_noise_detector.py => noise_detector.py} (58%) rename giskard_vision/landmark_detection/detectors/{cropping_detector.py => crop_detector.py} (77%) rename giskard_vision/landmark_detection/detectors/{transformation_resize_detector.py => resize_detector.py} (73%) diff --git a/examples/image_classification/load_datasets.ipynb b/examples/image_classification/load_datasets.ipynb deleted file mode 100644 index 78738570..00000000 --- a/examples/image_classification/load_datasets.ipynb +++ /dev/null @@ -1,211 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "0ff37ce4-4f98-4b98-9fe4-0b943c9c8949", - "metadata": {}, - "outputs": [], - "source": [ - "from giskard_vision.image_classification.dataloaders.loaders import *" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "cd697b1c-ab0b-4f8e-8183-9e5fe09b39c6", - "metadata": {}, - "outputs": [], - "source": [ - "gcs = DataLoaderGeirhosConflictStimuli()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "ca0a76d9-20c0-41bc-a194-a3817ed85d81", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/inoki/.virtualenvs/giskard-vision/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n" - ] - } - ], - "source": [ - "sc = DataLoaderSkinCancerHuggingFaceDataset()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "4f55117c-5641-4b36-be15-613228caa025", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2024-07-23 12:13:33.681629: W tensorflow/core/kernels/data/cache_dataset_ops.cc:858] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.\n" - ] - }, - { - "data": { - "text/plain": [ - "(224, 224, 3)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "gcs.get_image(0).shape" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "2108d5be-5bd4-45dd-a7b9-54c7128f279a", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2024-07-23 12:13:33.714646: W tensorflow/core/kernels/data/cache_dataset_ops.cc:858] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.\n" - ] - }, - { - "data": { - "text/plain": [ - "array(['clock'], dtype=' is available for this model. Using slow image processor class. To use the fast image processor class set `use_fast=True`.\n" - ] - } - ], - "source": [ - "m1 = SkinCancerHuggingFaceModel()" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "a2a21164-cbdb-4f19-8106-3762dc037501", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([1.83466705e-03, 1.25676964e-03, 9.79788959e-01, 7.34477013e-04,\n", - " 1.28028123e-03, 1.40569434e-02, 1.04791753e-03])" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "m1.predict_probas(sc.get_image(0))" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "e7905124-ed98-4518-b1a5-c94eb419b44f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array(['actinic_keratoses'], dtype='