Download scripts/check_robustness.py from Mohansree/bsure-api: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_robustness.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/check_robustness.py
-
curl -L -o check_robustness.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_robustness.py
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() | |