| import requests | |
| # Your deployed API URL | |
| api_url = "https://ali124k-124-HP-1.hf.space/predict" | |
| # Path to the image you want to classify | |
| image_path = "Apple_scab.jpg" # <-- replace this with your image path | |
| # Open image file in binary mode | |
| with open(image_path, "rb") as image_file: | |
| files = {"file": image_file} | |
| response = requests.post(api_url, files=files) | |
| # Check response status | |
| if response.status_code == 200: | |
| result = response.json() | |
| print("Prediction:", result["prediction"]) | |
| print("Confidence:", result["confidence"]) | |
| else: | |
| print("Error:", response.status_code) | |
| print(response.text) | |