Update handler.py
Browse files- handler.py +9 -2
handler.py
CHANGED
|
@@ -17,8 +17,15 @@ class EndpointHandler:
|
|
| 17 |
if not url:
|
| 18 |
return {"error": "Missing URL"}
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
inputs = self.processor(
|
| 24 |
text="<MORE_DETAILED_CAPTION>",
|
|
|
|
| 17 |
if not url:
|
| 18 |
return {"error": "Missing URL"}
|
| 19 |
|
| 20 |
+
headers = {
|
| 21 |
+
"User-Agent": "Mozilla/5.0",
|
| 22 |
+
"Accept": "image/*"
|
| 23 |
+
}
|
| 24 |
+
response = requests.get(url, headers=headers, verify=False)
|
| 25 |
+
response.raise_for_status()
|
| 26 |
+
|
| 27 |
+
image_data = io.BytesIO(response.content)
|
| 28 |
+
image = Image.open(image_data).convert("RGB")
|
| 29 |
|
| 30 |
inputs = self.processor(
|
| 31 |
text="<MORE_DETAILED_CAPTION>",
|