| import requests | |
| import os | |
| url = "http://127.0.0.1:8000/detect" | |
| # Use a dummy small image or any file | |
| # Since I don't have a real image handy that I'm sure of, I'll try to find one or create a dummy | |
| # Actually, I'll just check if there are any images in the directory | |
| files = [f for f in os.listdir('.') if f.endswith(('.jpg', '.png'))] | |
| if not files: | |
| print("No images found for testing.") | |
| else: | |
| img_path = files[0] | |
| with open(img_path, 'rb') as f: | |
| r = requests.post(url, files={'file': f}, data={'model': 'yolo'}) | |
| print(f"Status Code: {r.status_code}") | |
| if r.status_code == 200: | |
| data = r.json() | |
| print("Comparison Keys:", data.get('comparison', {}).keys()) | |
| print("Full Comparison:", data.get('comparison')) | |
| else: | |
| print(f"Error: {r.text}") | |