Yan
commited on
Commit
•
609d64d
1
Parent(s):
1a1a779
removed useless character from the file, removed specific endpoint url from endpoint tester
Browse files- endpoint_tester.py +1 -1
- handler.py +1 -2
endpoint_tester.py
CHANGED
@@ -5,7 +5,7 @@ import base64
|
|
5 |
from PIL import Image
|
6 |
from io import BytesIO
|
7 |
|
8 |
-
ENDPOINT_URL = "https://
|
9 |
HF_TOKEN = "#######################" # your huggingface token `hf_xxx`
|
10 |
|
11 |
# helper image utils
|
|
|
5 |
from PIL import Image
|
6 |
from io import BytesIO
|
7 |
|
8 |
+
ENDPOINT_URL = "https://XXXXXX" # your endpoint url
|
9 |
HF_TOKEN = "#######################" # your huggingface token `hf_xxx`
|
10 |
|
11 |
# helper image utils
|
handler.py
CHANGED
@@ -79,7 +79,6 @@ class EndpointHandler():
|
|
79 |
reverse_norm_std = torch.tensor([0.26862954, 0.26130258, 0.27577711])[:, None, None]
|
80 |
image_tensor = image_tensor * reverse_norm_std + reverse_norm_mean
|
81 |
pil_img = T.ToPILImage()(image_tensor)
|
82 |
-
a
|
83 |
image_h = pil_img.height
|
84 |
image_w = pil_img.width
|
85 |
image = np.array(pil_img)[:, :, [2, 1, 0]]
|
@@ -256,5 +255,5 @@ class EndpointHandler():
|
|
256 |
def decode_base64_image(self, image_string):
|
257 |
base64_image = base64.b64decode(image_string)
|
258 |
buffer = BytesIO(base64_image)
|
259 |
-
image = Image.open(buffer)
|
260 |
return image
|
|
|
79 |
reverse_norm_std = torch.tensor([0.26862954, 0.26130258, 0.27577711])[:, None, None]
|
80 |
image_tensor = image_tensor * reverse_norm_std + reverse_norm_mean
|
81 |
pil_img = T.ToPILImage()(image_tensor)
|
|
|
82 |
image_h = pil_img.height
|
83 |
image_w = pil_img.width
|
84 |
image = np.array(pil_img)[:, :, [2, 1, 0]]
|
|
|
255 |
def decode_base64_image(self, image_string):
|
256 |
base64_image = base64.b64decode(image_string)
|
257 |
buffer = BytesIO(base64_image)
|
258 |
+
image = Image.open(buffer).convert("RGB")
|
259 |
return image
|