File size: 903 Bytes
0ee3a29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """
Test script for the HuggingFace Space API
"""
from gradio_client import Client
import sys
try:
print("Connecting to HuggingFace Space...")
client = Client("smartfalcon-ai/Industrial-Defect-Detection")
print("[OK] Connected successfully!")
print(f"\nSpace URL: {client.space_id}")
# Test with a simple test - create a dummy image
print("\nTesting API with test image...")
import numpy as np
from PIL import Image
import io
import base64
# Create a simple test image (640x640 RGB)
test_img = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
result = client.predict(
test_img,
"Data Matrix",
0.25,
api_name="/predict"
)
print("[OK] API call successful!")
print(f"\nResult type: {type(result)}")
print(f"Result: {result}")
except Exception as e:
print(f"[ERROR] {e}")
sys.exit(1)
|