Update handler.py
Browse files- handler.py +2 -1
handler.py
CHANGED
|
@@ -2,6 +2,7 @@ from transformers import AutoModelForCausalLM, AutoProcessor
|
|
| 2 |
from PIL import Image
|
| 3 |
import requests
|
| 4 |
import torch
|
|
|
|
| 5 |
|
| 6 |
class EndpointHandler:
|
| 7 |
def __init__(self, model_dir):
|
|
@@ -17,7 +18,7 @@ class EndpointHandler:
|
|
| 17 |
return {"error": "Missing URL"}
|
| 18 |
|
| 19 |
response = requests.get(url, verify=False)
|
| 20 |
-
image = Image.open(response.
|
| 21 |
|
| 22 |
inputs = self.processor(
|
| 23 |
text="<MORE_DETAILED_CAPTION>",
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import requests
|
| 4 |
import torch
|
| 5 |
+
import io
|
| 6 |
|
| 7 |
class EndpointHandler:
|
| 8 |
def __init__(self, model_dir):
|
|
|
|
| 18 |
return {"error": "Missing URL"}
|
| 19 |
|
| 20 |
response = requests.get(url, verify=False)
|
| 21 |
+
image = Image.open(io.BytesIO(response.content)).convert("RGB")
|
| 22 |
|
| 23 |
inputs = self.processor(
|
| 24 |
text="<MORE_DETAILED_CAPTION>",
|