Spaces:
Sleeping
Sleeping
Download check_basic.py from Bhishaj/MerchFlow-AI: direct link, hf CLI and curl.
- Browser
- Download file 616 Bytes
-
https://huggingface.co/spaces/Bhishaj/MerchFlow-AI/resolve/main/check_basic.py
- Command line
-
hf download hf://spaces/Bhishaj/MerchFlow-AI/check_basic.py
-
curl -L -o check_basic.py https://huggingface.co/spaces/Bhishaj/MerchFlow-AI/resolve/main/check_basic.py
616 Bytes
| 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) | |