Coder Social home page Coder Social logo

woctezuma / stable-diffusion-safety-checker Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 36 KB

Python package to apply the Safety Checker from Stable Diffusion.

Home Page: https://github.com/Stability-AI/generative-models

License: MIT License

Python 71.73% Jupyter Notebook 28.27%
nsfw nsfw-classifier nsfw-detection nsfw-detector nsfw-recognition safety safety-check safety-checks stable-diffusion safety-checker

stable-diffusion-safety-checker's Introduction

Stable Diffusion Safety Checker

The goal of this repository is to run the safety checker from Stable Diffusion.

Requirements

  • Install the latest version of Python 3.
  • Install the required packages:
!pip install git+https://github.com/woctezuma/stable-diffusion-safety-checker.git

Usage

  • Run the main script with:
!python -m safety_checker.check_safety -h

Example

Download the balloon image dataset.

fname = "balloon_dataset.zip"
!curl -OL https://github.com/matterport/Mask_RCNN/releases/download/v2.1/{fname}
!unzip -q {fname}

Run the script:

!python -m safety_checker.check_safety \
 --input balloon \
 --batch 8 \
 --resize 256 \
 --keep-ratio \
 --output bad_concepts.json \
 --scores bad_concepts_scores.pth \
 --list img_list.json \
 --verbose

Check the results:

import json

from pathlib import Path

with Path("bad_concepts.json").open(encoding='utf8') as f:
  results = json.load(f)

The IDs of the "bad concepts" are clarified on this page hosted by LAION-AI.

References

stable-diffusion-safety-checker's People

Contributors

woctezuma avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.