Giter VIP home page Giter VIP logo

zsvcip's Introduction

Zero-shot Visual Commonsense Immorality Prediction

Official implementation is released by the authors.

This is an unofficial implementation of the paper, Zero-shot Visual Commonsense Immorality Prediction [Jeong+, BMVC2022].
Note that the paper might contain images and descriptions of an offensive nature and that this repository uses data described in the paper.

Requirements

  • Python 3.8+
  • PyTorch (tested with 1.12.1)
conda create -n zsvcip python=3.8
conda activate zsvcip
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
pip install -r requirements.txt
pip install -e .

Usage

Dataset

This repository provides a script to prepare the ETHICS dataset. See datasets/README.md for more details.

python datasets/prepare_ethics.py

Train

python tools/train.py

To change configuration from the command line, type "--" followed by a space-separated list of keys and values.

python tools/train.py \
  -- \
  input.batch_size 16 \
  model.clip_model openai/clip-vit-base-patch16

Evaluation

python tools/evaluate.py \
  -- \
  resume outputs/latest.pth

Inference

python tools/inference.py \
  -i 'hello world' \
  -m text \
  -- \
  resume outputs/latest.pth

Zero-shot prediction

For zero-shot prediction, this repository provides a code to download images from Bing by specifying keywords.

python tools/image_crawler.py \
  --root_dir cat \
  --keyword 'cat' \
  --license 'creativecommons' \
  -n 1

To input an image into the network, it is necessary to change the mode and the network architecture as follows:

python tools/inference.py \
  -i cat/000001.jpg \
  -m image \
  -- \
  resume outputs/latest.pth \
  model.arch image

Citation

@inproceedings{Jeong_2022_BMVC,
author    = {Yujin Jeong and Seongbeom Park and Suhong Moon and Jinkyu Kim},
title     = {Zero-shot Visual Commonsense Immorality Prediction},
booktitle = {33rd British Machine Vision Conference 2022, {BMVC} 2022, London, UK, November 21-24, 2022},
publisher = {{BMVA} Press},
year      = {2022},
url       = {https://bmvc2022.mpi-inf.mpg.de/0320.pdf}
}

zsvcip's People

Contributors

seiyaito avatar

Watchers

 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.