asoderznik
commited on
Commit
•
2c745bf
1
Parent(s):
4fa2b44
Update handler.py
Browse files- handler.py +7 -6
handler.py
CHANGED
@@ -16,15 +16,16 @@ logger.warning("WARN")
|
|
16 |
# set device
|
17 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
18 |
|
19 |
-
if device.type != 'cuda':
|
20 |
-
raise ValueError("need to run on GPU")
|
21 |
|
22 |
class EndpointHandler():
|
23 |
def __init__(self, path=""):
|
|
|
24 |
# load the optimized model
|
25 |
#model_id = "stabilityai/stable-diffusion-x4-upscaler"
|
26 |
-
self.pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
|
27 |
-
self.pipe = self.pipe.to(device)
|
28 |
|
29 |
|
30 |
def __call__(self, *args, **kwargs) -> List[Dict[str, Any]]:
|
@@ -34,8 +35,8 @@ class EndpointHandler():
|
|
34 |
Return:
|
35 |
A :obj:`dict`:. base64 encoded image
|
36 |
"""
|
37 |
-
|
38 |
-
|
39 |
|
40 |
# postprocess the prediction
|
41 |
return {"image": "nothing"}
|
|
|
16 |
# set device
|
17 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
18 |
|
19 |
+
#if device.type != 'cuda':
|
20 |
+
#raise ValueError("need to run on GPU")
|
21 |
|
22 |
class EndpointHandler():
|
23 |
def __init__(self, path=""):
|
24 |
+
self.path = path
|
25 |
# load the optimized model
|
26 |
#model_id = "stabilityai/stable-diffusion-x4-upscaler"
|
27 |
+
#self.pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
|
28 |
+
#self.pipe = self.pipe.to(device)
|
29 |
|
30 |
|
31 |
def __call__(self, *args, **kwargs) -> List[Dict[str, Any]]:
|
|
|
35 |
Return:
|
36 |
A :obj:`dict`:. base64 encoded image
|
37 |
"""
|
38 |
+
logger.info('args received %s', args)
|
39 |
+
logger.info('kwargs received %s', kwargs)
|
40 |
|
41 |
# postprocess the prediction
|
42 |
return {"image": "nothing"}
|