Transformers
PyTorch
clip

Fix: Invalid import of SafetyChecker in example code

#49

Description

The example code in the model card fails with the following error:

from transformers import AutoProcessor, SafetyChecker
# ImportError: cannot import name 'SafetyChecker' from 'transformers'

Changes

Replaced:

from transformers import AutoProcessor, SafetyChecker

with:

from transformers import CLIPFeatureExtractor as AutoProcessor
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker as SafetyChecker

Testing

The code has been successfully tested and runs without error.

Note

This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment