400 Error on Falconsai/nsfw_image_detection

I am getting
`HTTPError: 400 Client Error: Bad Request for url: https://huggingface.co/static-proxy/router.huggingface.co/hf-inference/models/Falconsai/nsfw_image_detection` for the Falconsai/nsfw_image_detection model
Please help

3 Likes

Hmm… Weird… @Wauplin @michellehbn

import os, requests
from huggingface_hub import InferenceClient
from io import BytesIO
from PIL import Image
from transformers import pipeline

model_id = "Falconsai/nsfw_image_detection"
#model_id = "beingamit99/car_damage_detection"

image_url = "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg"
res = requests.get(image_url, timeout=20)
res.raise_for_status()
image_bytes = res.content
pil_image = Image.open(BytesIO(image_bytes))

classifier = pipeline("image-classification", model=model_id)
print(classifier(pil_image))
#[{'label': 'normal', 'score': 0.9886492490768433}, {'label': 'nsfw', 'score': 0.009994533844292164}]

client = InferenceClient(
    provider="hf-inference",
    api_key=os.getenv("HF_TOKEN", None),
)

output = client.image_classification(image_url, model=model_id)
#Bad request:
#'NoneType' object has no attribute 'lower'
output = client.image_classification(image_bytes, model=model_id)
#Bad request:
#'NoneType' object has no attribute 'lower'

Exactly, I am also getting similar errors

1 Like

yes sometime a have also this type of error

1 Like