400 Client Error: Bad Request for url

I get the following error when I try to use the inference API:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api-inference.huggingface.co/models/MIT/ast-finetuned-audioset-10-10-0.4593

This url is directly taken from https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593 so I dont know what is wrong.

I tested it with a 1 second long .wav file read into bytes. Seems it isnt working though.

2 Likes

Same error with Falconsai/nsfw_image_detection also

1 Like

True… Weird…

import os, requests
from huggingface_hub import InferenceClient

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

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

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

Image Classification