Updated Handler to have better debugging output when encountering errors trying to generate mesh
Browse files- handler.py +23 -2
handler.py
CHANGED
|
@@ -64,6 +64,15 @@ class EndpointHandler():
|
|
| 64 |
|
| 65 |
def __call__(self, input_data: Any) -> Any:
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
command = "null"
|
| 68 |
|
| 69 |
if "command" in input_data:
|
|
@@ -79,7 +88,20 @@ class EndpointHandler():
|
|
| 79 |
elif command == "generate_pc":
|
| 80 |
return self.generate_point_cloud(input_data)
|
| 81 |
elif command == "generate_mesh":
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
elif command == "status":
|
| 84 |
return self.check_status()
|
| 85 |
|
|
@@ -144,7 +166,6 @@ class EndpointHandler():
|
|
| 144 |
#image = self.pipe(inputs, guidance_scale=7.5)["sample"][0]
|
| 145 |
|
| 146 |
pc = sampler.output_to_point_clouds(samples)[0]
|
| 147 |
-
|
| 148 |
pc_dict = {}
|
| 149 |
|
| 150 |
data_list = pc.coords.tolist()
|
|
|
|
| 64 |
|
| 65 |
def __call__(self, input_data: Any) -> Any:
|
| 66 |
|
| 67 |
+
# Check if input_data is a string and deserialize if necessary
|
| 68 |
+
if isinstance(input_data, str):
|
| 69 |
+
print("input_data is a string, attempting to deserialize...")
|
| 70 |
+
try:
|
| 71 |
+
input_data = json.loads(input_data) # Convert JSON string to dictionary
|
| 72 |
+
except json.JSONDecodeError as e:
|
| 73 |
+
print(f"Failed to parse JSON: {e}")
|
| 74 |
+
return None # Handle the error as appropriate
|
| 75 |
+
|
| 76 |
command = "null"
|
| 77 |
|
| 78 |
if "command" in input_data:
|
|
|
|
| 88 |
elif command == "generate_pc":
|
| 89 |
return self.generate_point_cloud(input_data)
|
| 90 |
elif command == "generate_mesh":
|
| 91 |
+
print("generate_mesh command received...")
|
| 92 |
+
raw_pc = input_data.get("raw_pc")
|
| 93 |
+
|
| 94 |
+
if raw_pc is None:
|
| 95 |
+
print("raw_pc not found in input_data!")
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
# Check if raw_pc is a string and deserialize if necessary
|
| 99 |
+
if isinstance(raw_pc, str):
|
| 100 |
+
print("raw_pc is a string, attempting to deserialize...")
|
| 101 |
+
raw_pc = json.loads(raw_pc)
|
| 102 |
+
|
| 103 |
+
print("Calling generate_mesh_from_pc...")
|
| 104 |
+
return self.generate_mesh_from_pc(raw_pc)
|
| 105 |
elif command == "status":
|
| 106 |
return self.check_status()
|
| 107 |
|
|
|
|
| 166 |
#image = self.pipe(inputs, guidance_scale=7.5)["sample"][0]
|
| 167 |
|
| 168 |
pc = sampler.output_to_point_clouds(samples)[0]
|
|
|
|
| 169 |
pc_dict = {}
|
| 170 |
|
| 171 |
data_list = pc.coords.tolist()
|