Giter Club home page Giter Club logo

semantic-prototypes's Introduction

Semantic Prototypes: Enhancing Transparency Without Black Boxes

Dependencies

conda env create -f environment.yml
  • Add the conda environment to Jupyter.
python -m ipykernel install --user --name=protosem

Preprocess the CUB-200 Dataset like ProtoPNet

Follow these instructions to prepare the data:

  1. Download the dataset CUB_200_2011.tgz from http://www.vision.caltech.edu/visipedia/CUB-200-2011.html
  2. Unpack CUB_200_2011.tgz
  3. Crop the images using information from bounding_boxes.txt (included in the dataset)
  4. Split the cropped images into training and test sets, using train_test_split.txt (included in the dataset)
  5. Put the cropped training images in the directory "./datasets/cub200_cropped/train_cropped/"
  6. Put the cropped test images in the directory "./datasets/cub200_cropped/test_cropped/"

For cropping the images, you can use the preprocessing/crop_images.py script provided in this repository: Explaining_Prototypes.

Creating Class Cluster Descriptions

  1. Download CUB-200 at ...
  2. Copy the file attributes.txt from the outer CUB_200_2011 directory into the attributes subdirectory.
  3. Download and unzip CLEVR-Hans3. wget https://tudatalib.ulb.tu-darmstadt.de/bitstream/handle/tudatalib/2611/CLEVR-Hans3.zip unzip CLEVR-Hans3.zip
  4. CLEVR-Hans3 object attributes can be found preprocessed in CLEVR-Hans3_attributes.json
  5. Edit CUB-200 and CLEVR-Hans3 directory paths in compute_ccds.ipynb and then run it. The resulting CCDs will be saved in the results directory.

Creating Semantic Prototypes

For CUB-200 Edit the CUB-200 directory path in compute_prototypes.ipynb and then run it. The resulting prototypes for CUB-200 will be saved in the results directory.

For CLEVR-HANS3 Execute the script by running the following command in your terminal:

python clevr_hans.py "CLEVR-Hans3/train/CLEVR_HANS_scenes_train.json" num_of_label

Replace "CLEVR-Hans3/train/CLEVR_HANS_scenes_train.json" with the actual path to your JSON file, and num_of_label with the label number you want to retrieve prototypes for (valid options are 0, 1, or 2).

Example:

python clevr_hans.py "CLEVR-Hans3/train/CLEVR_HANS_scenes_train.json" 1

semantic-prototypes's People

Contributors

geofila avatar

Stargazers

Vassilis Lyberatos avatar

Watchers

George Alexandridis avatar Arne Stabenau avatar Panagiotis Tzortzis avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.