AIcoder35235 commited on
Commit
ee16559
·
verified ·
1 Parent(s): 58e4c57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -42,9 +42,13 @@ def predict(req: PredictRequest):
42
 
43
  # 1. Handle URL Input
44
  if req.image_url:
45
- response = requests.get(req.image_url, stream=True)
 
 
 
46
  if response.status_code != 200:
47
- raise Exception("Could not download image from URL.")
 
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