Spaces:
Running
Running
File size: 616 Bytes
842ca78 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import os
from huggingface_hub import InferenceClient
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("HF_TOKEN")
client = InferenceClient(api_key=api_key)
print(f"Testing token with microsoft/resnet-50")
try:
# Pass the URL directly as the input (InferenceClient handles URLs for image tasks)
result = client.image_classification(
model="microsoft/resnet-50",
image="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
)
print("Success:", result)
except Exception as e:
print("Failed:", e)
|