The goal of this repository is to run the safety checker from Stable Diffusion.
- Install the latest version of Python 3.
- Install the required packages:
!pip install git+https://github.com/woctezuma/stable-diffusion-safety-checker.git
- Run the main script with:
!python -m safety_checker.check_safety -h
- Alternatively, run
safety_checker.ipynb
.
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.
feature-extractor
: similar code to extract image features,discord-members-metadata
: profiles pictures scraped from a specific Discord guild's members.