asoderznik
commited on
Commit
•
be1c648
1
Parent(s):
ff2ef5c
Update handler.py
Browse files- handler.py +4 -4
handler.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from typing import Dict, List, Any
|
2 |
from PIL import Image
|
3 |
import torch
|
4 |
-
from torch import autocast
|
5 |
from diffusers import StableDiffusionUpscalePipeline
|
6 |
import base64
|
7 |
from io import BytesIO
|
@@ -24,9 +23,7 @@ class EndpointHandler():
|
|
24 |
self.path = path
|
25 |
# load the optimized model
|
26 |
#model_id = "stabilityai/stable-diffusion-x4-upscaler"
|
27 |
-
|
28 |
-
self.pipe = self.pipe.to(device)
|
29 |
-
|
30 |
|
31 |
def __call__(self, data) -> List[Dict[str, Any]]:
|
32 |
"""
|
@@ -35,6 +32,9 @@ class EndpointHandler():
|
|
35 |
Return:
|
36 |
A :obj:`dict`:. base64 encoded image
|
37 |
"""
|
|
|
|
|
|
|
38 |
logger.info('data received %s', data)
|
39 |
inputs = data.get("inputs")
|
40 |
logger.info('inputs received %s', inputs)
|
|
|
1 |
from typing import Dict, List, Any
|
2 |
from PIL import Image
|
3 |
import torch
|
|
|
4 |
from diffusers import StableDiffusionUpscalePipeline
|
5 |
import base64
|
6 |
from io import BytesIO
|
|
|
23 |
self.path = path
|
24 |
# load the optimized model
|
25 |
#model_id = "stabilityai/stable-diffusion-x4-upscaler"
|
26 |
+
|
|
|
|
|
27 |
|
28 |
def __call__(self, data) -> List[Dict[str, Any]]:
|
29 |
"""
|
|
|
32 |
Return:
|
33 |
A :obj:`dict`:. base64 encoded image
|
34 |
"""
|
35 |
+
|
36 |
+
self.pipe = StableDiffusionUpscalePipeline.from_pretrained(path, torch_dtype=torch.float16)
|
37 |
+
self.pipe = self.pipe.to(device)
|
38 |
logger.info('data received %s', data)
|
39 |
inputs = data.get("inputs")
|
40 |
logger.info('inputs received %s', inputs)
|