fixing
Browse files- handler.py +10 -4
handler.py
CHANGED
|
@@ -9,10 +9,10 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
| 9 |
|
| 10 |
class EndpointHandler():
|
| 11 |
def __init__(self, path=""):
|
| 12 |
-
model_id = "timbrooks/instruct-pix2pix"
|
| 13 |
-
self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
|
| 14 |
-
self.pipe.to(device)
|
| 15 |
-
self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
| 16 |
|
| 17 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 18 |
"""
|
|
@@ -23,6 +23,12 @@ class EndpointHandler():
|
|
| 23 |
A :obj:`string`:. Base64 encoded image string
|
| 24 |
"""
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
image_data = data.pop("inputs", data)
|
| 27 |
# decode base64 image to PIL
|
| 28 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
|
|
|
| 9 |
|
| 10 |
class EndpointHandler():
|
| 11 |
def __init__(self, path=""):
|
| 12 |
+
#model_id = "timbrooks/instruct-pix2pix"
|
| 13 |
+
#self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
|
| 14 |
+
#self.pipe.to(device)
|
| 15 |
+
#self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
| 16 |
|
| 17 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 18 |
"""
|
|
|
|
| 23 |
A :obj:`string`:. Base64 encoded image string
|
| 24 |
"""
|
| 25 |
|
| 26 |
+
model_id = "timbrooks/instruct-pix2pix"
|
| 27 |
+
self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
|
| 28 |
+
self.pipe.to(device)
|
| 29 |
+
self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
image_data = data.pop("inputs", data)
|
| 33 |
# decode base64 image to PIL
|
| 34 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|