bsure-api / scripts /debug_classifier_real.py
“mohansree14”
Deploy Bsure API with correct structure
af1d8cd
Raw History Blame Contribute Delete
1.07 kB
from services.classifier import classify_garment
import requests
import os
def test_real():
print("Downloading sample Jeans image...")
# Get a real image of jeans
img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Jeans.jpg/440px-Jeans.jpg"
with open("temp_jeans.jpg", "wb") as f:
f.write(requests.get(img_url).content)
print("Calling Classifier Service...")
# Check token visibility
if os.path.exists("hf_token.txt"):
print("hf_token.txt found.")
with open("hf_token.txt", "r") as f:
print(f"Token start: {f.read().strip()[:5]}...")
else:
print("❌ hf_token.txt NOT FOUND in cwd")
cat, desc, tags = classify_garment("temp_jeans.jpg")
print("\n--- RESULTS ---")
print(f"Category: {cat}")
print(f"Description: {desc}")
print(f"Tags: {tags}")
if cat == "bottom":
print("✅ SUCCESS: Detected matching bottom")
else:
print("❌ FAILURE: Did not detect bottom")
if __name__ == "__main__":
test_real()