Andrew Luo
commited on
Commit
·
ec3bbda
1
Parent(s):
865f97a
external url
Browse files- handler.py +4 -1
- requirements.txt +2 -1
handler.py
CHANGED
|
@@ -2,6 +2,8 @@ from transformers import VisionEncoderDecoderModel, ViTImageProcessor, AutoToken
|
|
| 2 |
import torch
|
| 3 |
from PIL import Image
|
| 4 |
from typing import Dict, List, Any
|
|
|
|
|
|
|
| 5 |
|
| 6 |
class EndpointHandler():
|
| 7 |
def __init__(self, path=""):
|
|
@@ -34,7 +36,8 @@ class EndpointHandler():
|
|
| 34 |
image_paths = data.pop("image_paths", data)
|
| 35 |
images = []
|
| 36 |
for image_path in image_paths:
|
| 37 |
-
|
|
|
|
| 38 |
if i_image.mode != "RGB":
|
| 39 |
i_image = i_image.convert(mode="RGB")
|
| 40 |
|
|
|
|
| 2 |
import torch
|
| 3 |
from PIL import Image
|
| 4 |
from typing import Dict, List, Any
|
| 5 |
+
import urllib.request
|
| 6 |
+
|
| 7 |
|
| 8 |
class EndpointHandler():
|
| 9 |
def __init__(self, path=""):
|
|
|
|
| 36 |
image_paths = data.pop("image_paths", data)
|
| 37 |
images = []
|
| 38 |
for image_path in image_paths:
|
| 39 |
+
urllib.request.urlretrieve(image_path, "temp")
|
| 40 |
+
i_image = Image.open("temp")
|
| 41 |
if i_image.mode != "RGB":
|
| 42 |
i_image = i_image.convert(mode="RGB")
|
| 43 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
torch
|
| 2 |
transformers
|
| 3 |
-
Pillow
|
|
|
|
|
|
| 1 |
torch
|
| 2 |
transformers
|
| 3 |
+
Pillow
|
| 4 |
+
urllib3
|