Views
No views yet
OpenSafetyLab/t2i_safety_dataset (available at kricko/cleaned_auditor).return_heatmaps=True).auditor_inference.py script for standalone inference with visual explanations.1python3 auditor_inference.py \
2 --model complete_auditor_best.pth \
3 --vocab vocab.json \
4 --image your_image.jpg \
5 --prompt "a prompt corresponding to the image"your_image_adv_heatmap.jpg and class-specific heatmaps to your current directory.1from auditor_inference import audit_image
2
3results = audit_image(
4 model_path="complete_auditor_best.pth",
5 image_path="sample.jpg",
6 prompt="a sample prompt",
7 return_heatmaps=True
8)
9
10print(results["is_adversarial"])
11# Heatmaps are available as numpy arrays (original image size)
12# results["adversarial_heatmap"]
13# results["category_heatmaps"]["Violence"]