Commit
·
478e105
1
Parent(s):
db99c4e
Update handler.py
Browse files- handler.py +13 -5
handler.py
CHANGED
|
@@ -28,19 +28,27 @@ class EndpointHandler():
|
|
| 28 |
A :obj:`dict`:. base64 encoded image
|
| 29 |
"""
|
| 30 |
inputs = data.pop("inputs", data)
|
|
|
|
| 31 |
print(inputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# decode base64 image to PIL
|
| 34 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
|
|
|
| 35 |
print(image)
|
|
|
|
| 36 |
|
| 37 |
# run inference pipeline
|
| 38 |
-
upscaled_image = self.pipe(prompt="", image = image).images[0]
|
| 39 |
|
| 40 |
# encode image as base 64
|
| 41 |
-
buffered = BytesIO()
|
| 42 |
-
upscaled_image.save(buffered, format="JPEG")
|
| 43 |
-
img_str = base64.b64encode(buffered.getvalue())
|
| 44 |
|
| 45 |
# postprocess the prediction
|
| 46 |
-
return {"image": img_str.decode()}
|
|
|
|
| 28 |
A :obj:`dict`:. base64 encoded image
|
| 29 |
"""
|
| 30 |
inputs = data.pop("inputs", data)
|
| 31 |
+
print("Printing inputs")
|
| 32 |
print(inputs)
|
| 33 |
+
print("")
|
| 34 |
+
|
| 35 |
+
print("Printing image")
|
| 36 |
+
print(inputs['image'])
|
| 37 |
+
print("")
|
| 38 |
|
| 39 |
# decode base64 image to PIL
|
| 40 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
| 41 |
+
print("Printing loaded image into library")
|
| 42 |
print(image)
|
| 43 |
+
print("")
|
| 44 |
|
| 45 |
# run inference pipeline
|
| 46 |
+
#upscaled_image = self.pipe(prompt="", image = image).images[0]
|
| 47 |
|
| 48 |
# encode image as base 64
|
| 49 |
+
#buffered = BytesIO()
|
| 50 |
+
#upscaled_image.save(buffered, format="JPEG")
|
| 51 |
+
#img_str = base64.b64encode(buffered.getvalue())
|
| 52 |
|
| 53 |
# postprocess the prediction
|
| 54 |
+
return {"image": "img_str.decode()"}
|