andreped commited on
Commit
c6b094e
1 Parent(s): f26565c

Added back run_model method

Browse files
Files changed (2) hide show
  1. demo/src/gui.py +6 -6
  2. demo/src/utils.py +7 -0
demo/src/gui.py CHANGED
@@ -75,12 +75,12 @@ class WebUI:
75
 
76
  def process(self, mesh_file_name):
77
  path = mesh_file_name.name
78
- #run_model(
79
- # path,
80
- # model_path=os.path.join(self.cwd, "resources/models/"),
81
- # task=self.class_names[self.class_name],
82
- # name=self.result_names[self.class_name],
83
- #)
84
  LOGGER.info("Converting prediction NIfTI to OBJ...")
85
  nifti_to_glb("prediction.nii.gz")
86
 
 
75
 
76
  def process(self, mesh_file_name):
77
  path = mesh_file_name.name
78
+ run_model(
79
+ path,
80
+ model_path=os.path.join(self.cwd, "resources/models/"),
81
+ task=self.class_names[self.class_name],
82
+ name=self.result_names[self.class_name],
83
+ )
84
  LOGGER.info("Converting prediction NIfTI to OBJ...")
85
  nifti_to_glb("prediction.nii.gz")
86
 
demo/src/utils.py CHANGED
@@ -46,12 +46,19 @@ def nifti_to_glb(path, output="prediction.obj"):
46
  resampled = resample_to_output(image, [1, 1, 1], order=1)
47
  data = resampled.get_fdata().astype("uint8")
48
 
 
 
 
49
  # extract surface
50
  verts, faces, normals, values = marching_cubes(data, 0)
51
  faces += 1
52
 
53
  with open(output, "w") as thefile:
 
 
 
54
  for item in verts:
 
55
  thefile.write("v {0} {1} {2}\n".format(item[0], item[1], item[2]))
56
 
57
  for item in normals:
 
46
  resampled = resample_to_output(image, [1, 1, 1], order=1)
47
  data = resampled.get_fdata().astype("uint8")
48
 
49
+ # Create a material with a red diffuse color (RGB value)
50
+ red_material = "newmtl RedMaterial\nKd 1 0 0" # Red diffuse color (RGB)
51
+
52
  # extract surface
53
  verts, faces, normals, values = marching_cubes(data, 0)
54
  faces += 1
55
 
56
  with open(output, "w") as thefile:
57
+ # Write the material definition to the OBJ file
58
+ thefile.write(red_material + "\n")
59
+
60
  for item in verts:
61
+ #thefile.write('usemtl RedMaterial\n')
62
  thefile.write("v {0} {1} {2}\n".format(item[0], item[1], item[2]))
63
 
64
  for item in normals: