Thomas Male commited on
Commit
35da4d4
·
verified ·
1 Parent(s): f18894a

Update handler.py

Browse files
Files changed (1) hide show
  1. 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
- image_data = data.pop("image")
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
- sampler = PointCloudSampler(
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
- img = Image.open('example_data/cube_stack.jpg')
 
 
 
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,