Thomas Male commited on
Commit
5260df5
·
1 Parent(s): db2ce80

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +10 -8
handler.py CHANGED
@@ -71,16 +71,18 @@ class EndpointHandler():
71
 
72
  pc = sampler.output_to_point_clouds(samples)[0]
73
  print('type of pc: ', type(pc))
 
 
74
 
75
  data_list = pc.coords.tolist()
76
  json_string = json.dumps(data_list)
77
- return {"data": json_string}
78
- #print(pc)
79
 
80
- # encode image as base 64
81
- #buffered = BytesIO()
82
- #image.save(buffered, format="JPEG")
83
- #img_str = base64.b64encode(buffered.getvalue())
84
 
85
- # postprocess the prediction
86
- #return {"image": img_str.decode()}
 
 
 
 
71
 
72
  pc = sampler.output_to_point_clouds(samples)[0]
73
  print('type of pc: ', type(pc))
74
+
75
+ pc_dict = {}
76
 
77
  data_list = pc.coords.tolist()
78
  json_string = json.dumps(data_list)
79
+ pc_dict['data'] = json_string
 
80
 
81
+ # Convert NumPy arrays to Python lists for serializing
82
+ serializable_channels = {key: value.tolist() for key, value in pc.channels.items()}
 
 
83
 
84
+ # Serialize the dictionary to a JSON-formatted string
85
+ channel_data = json.dumps(serializable_channels)
86
+ pc_dict['channels'] = channel_data
87
+
88
+ return pc_dict