Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,9 +42,13 @@ def predict(req: PredictRequest):
|
|
| 42 |
|
| 43 |
# 1. Handle URL Input
|
| 44 |
if req.image_url:
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
| 46 |
if response.status_code != 200:
|
| 47 |
-
raise Exception("Could not download image
|
|
|
|
| 48 |
img = Image.open(response.raw).convert("RGB")
|
| 49 |
|
| 50 |
# 2. Handle Base64 Input
|
|
|
|
| 42 |
|
| 43 |
# 1. Handle URL Input
|
| 44 |
if req.image_url:
|
| 45 |
+
# The fake ID card so Wikipedia lets our AI download the image
|
| 46 |
+
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
|
| 47 |
+
response = requests.get(req.image_url, stream=True, headers=headers)
|
| 48 |
+
|
| 49 |
if response.status_code != 200:
|
| 50 |
+
raise Exception(f"Could not download image. Server returned: {response.status_code}")
|
| 51 |
+
|
| 52 |
img = Image.open(response.raw).convert("RGB")
|
| 53 |
|
| 54 |
# 2. Handle Base64 Input
|