Thomas Male
commited on
Update handler.py
Browse files- handler.py +6 -3
handler.py
CHANGED
|
@@ -60,7 +60,7 @@ class EndpointHandler():
|
|
| 60 |
|
| 61 |
#Checks if an image key has been provided, and if so, uses the image data instead of text input
|
| 62 |
if "image" in data:
|
| 63 |
-
|
| 64 |
use_image = True
|
| 65 |
print('image data found')
|
| 66 |
else:
|
|
@@ -70,7 +70,7 @@ class EndpointHandler():
|
|
| 70 |
inputs = data.pop("inputs", data)
|
| 71 |
|
| 72 |
if use_image:
|
| 73 |
-
|
| 74 |
device=device,
|
| 75 |
models=[base_model, upsampler_model],
|
| 76 |
diffusions=[base_diffusion, upsampler_diffusion],
|
|
@@ -80,7 +80,10 @@ class EndpointHandler():
|
|
| 80 |
)
|
| 81 |
|
| 82 |
# Load an image to condition on.
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 84 |
else:
|
| 85 |
sampler = PointCloudSampler(
|
| 86 |
device=device,
|
|
|
|
| 60 |
|
| 61 |
#Checks if an image key has been provided, and if so, uses the image data instead of text input
|
| 62 |
if "image" in data:
|
| 63 |
+
image_data_encoded = data.pop("image")
|
| 64 |
use_image = True
|
| 65 |
print('image data found')
|
| 66 |
else:
|
|
|
|
| 70 |
inputs = data.pop("inputs", data)
|
| 71 |
|
| 72 |
if use_image:
|
| 73 |
+
sampler = PointCloudSampler(
|
| 74 |
device=device,
|
| 75 |
models=[base_model, upsampler_model],
|
| 76 |
diffusions=[base_diffusion, upsampler_diffusion],
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
# Load an image to condition on.
|
| 83 |
+
image_data = base64.b64decode(image_data_encoded)
|
| 84 |
+
|
| 85 |
+
# Convert bytes to PIL Image
|
| 86 |
+
img = Image.open(BytesIO(image_data))
|
| 87 |
else:
|
| 88 |
sampler = PointCloudSampler(
|
| 89 |
device=device,
|