bsure-api / scripts /check_robustness.py
“mohansree14”
Deploy Bsure API with correct structure
af1d8cd
Raw History Blame Contribute Delete
1.34 kB
from services.classifier import classify_garment
import requests
import os
import shutil
def test_robustness():
print("Testing Classifier Robustness...")
# 1. Test with "Jeans.jpg" (Should be Bottom via Fallback if API fails)
img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Jeans.jpg/440px-Jeans.jpg"
filename = "Jeans.jpg" # Capitalized to test case insensitivity
with open(filename, "wb") as f:
f.write(requests.get(img_url).content)
print(f"\n1. input: {filename}")
cat, desc, tags = classify_garment(filename)
print(f" -> Result: Category={cat}, Desc={desc}, Source={tags}")
if cat == "bottom":
print("✅ SUCCESS: Detected matching bottom (Logic Works)")
else:
print("❌ FAILURE: Did not detect bottom")
# 2. Test with "black_tshirt.jpg" (Should be Top)
filename2 = "black_tshirt.jpg"
shutil.copy(filename, filename2) # Just copy content, name matters
print(f"\n2. input: {filename2}")
cat, desc, tags = classify_garment(filename2)
print(f" -> Result: Category={cat}, Desc={desc}, Source={tags}")
if cat == "top":
print("✅ SUCCESS: Detected matching top")
else:
print("❌ FAILURE: Failed top detection")
if __name__ == "__main__":
test_robustness()