Commit
·
4466a94
1
Parent(s):
b506ecc
update handler file
Browse files- handler.py +4 -1
handler.py
CHANGED
@@ -11,6 +11,7 @@ import cv2
|
|
11 |
|
12 |
|
13 |
import torch
|
|
|
14 |
torch.cuda.empty_cache()
|
15 |
torch.cuda.set_per_process_memory_fraction(0.5)
|
16 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:32,garbage_collection_threshold:0.7"
|
@@ -43,5 +44,7 @@ class EndpointHandler:
|
|
43 |
|
44 |
img_byte_arr = BytesIO()
|
45 |
output = Image.fromarray(output)
|
|
|
46 |
output.save(img_byte_arr, format='PNG')
|
47 |
-
|
|
|
|
11 |
|
12 |
|
13 |
import torch
|
14 |
+
import base64
|
15 |
torch.cuda.empty_cache()
|
16 |
torch.cuda.set_per_process_memory_fraction(0.5)
|
17 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:32,garbage_collection_threshold:0.7"
|
|
|
44 |
|
45 |
img_byte_arr = BytesIO()
|
46 |
output = Image.fromarray(output)
|
47 |
+
print(output.size)
|
48 |
output.save(img_byte_arr, format='PNG')
|
49 |
+
img_str = base64.b64encode(img_byte_arr.getvalue())
|
50 |
+
return {"out_image": img_str}
|