staswrs commited on
Commit
95553e7
·
1 Parent(s): cec312b

add octree depth controls fix 1

Browse files
Files changed (2) hide show
  1. app.py +13 -12
  2. inference_triposg.py +2 -2
app.py CHANGED
@@ -67,9 +67,10 @@ rmbg_net = BriaRMBG.from_pretrained(rmbg_path).to(device)
67
  rmbg_net.eval()
68
 
69
 
70
- # def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25):
71
- def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25, octree_depth=9):
72
- print(f"[INPUT] face_number={face_number}, guidance_scale={guidance_scale}, num_steps={num_steps}, octree_depth={octree_depth}")# 👈 добавлено
 
73
  print("[API CALL] image_path received:", image_path)
74
  print("[API CALL] File exists:", os.path.exists(image_path))
75
 
@@ -86,7 +87,7 @@ def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25, oc
86
  num_inference_steps=int(num_steps),
87
  guidance_scale=float(guidance_scale),
88
  faces=int(face_number),
89
- octree_depth=int(octree_depth), # 👈 добавлено
90
  )
91
 
92
  if mesh is None or mesh.vertices.shape[0] == 0 or mesh.faces.shape[0] == 0:
@@ -128,14 +129,14 @@ def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25, oc
128
  # Интерфейс Gradio
129
  demo = gr.Interface(
130
  fn=generate,
131
- # inputs=gr.Image(type="filepath", label="Upload image"),
132
- inputs=[
133
- gr.Image(type="filepath", label="Upload image"),
134
- gr.Slider(10000, 150000, step=10000, value=50000, label="Face count"),
135
- gr.Slider(1.0, 10.0, step=0.5, value=5.0, label="Guidance Scale"),
136
- gr.Slider(10, 100, step=5, value=25, label="Steps"),
137
- gr.Slider(6, 10, step=1, value=9, label="Octree Depth"),
138
- ], # 👈 добавлено
139
  outputs=gr.File(label="Download .glb"),
140
  title="TripoSG Image to 3D",
141
  description="Upload an image to generate a 3D model (.glb)",
 
67
  rmbg_net.eval()
68
 
69
 
70
+ def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25):
71
+ # def generate(image_path, face_number=50000, guidance_scale=5.0, num_steps=25, octree_depth=9):
72
+ # print(f"[INPUT] face_number={face_number}, guidance_scale={guidance_scale}, num_steps={num_steps}, octree_depth={octree_depth}")# 👈 добавлено
73
+ print(f"[INPUT] face_number={face_number}, guidance_scale={guidance_scale}, num_steps={num_steps}")# 👈 добавлено
74
  print("[API CALL] image_path received:", image_path)
75
  print("[API CALL] File exists:", os.path.exists(image_path))
76
 
 
87
  num_inference_steps=int(num_steps),
88
  guidance_scale=float(guidance_scale),
89
  faces=int(face_number),
90
+ # octree_depth=int(octree_depth), # 👈 добавлено
91
  )
92
 
93
  if mesh is None or mesh.vertices.shape[0] == 0 or mesh.faces.shape[0] == 0:
 
129
  # Интерфейс Gradio
130
  demo = gr.Interface(
131
  fn=generate,
132
+ inputs=gr.Image(type="filepath", label="Upload image"),
133
+ # inputs=[
134
+ # gr.Image(type="filepath", label="Upload image"),
135
+ # gr.Slider(10000, 150000, step=10000, value=50000, label="Face count"),
136
+ # gr.Slider(1.0, 10.0, step=0.5, value=5.0, label="Guidance Scale"),
137
+ # gr.Slider(10, 100, step=5, value=25, label="Steps"),
138
+ # gr.Slider(6, 10, step=1, value=9, label="Octree Depth"),
139
+ # ], # 👈 добавлено
140
  outputs=gr.File(label="Download .glb"),
141
  title="TripoSG Image to 3D",
142
  description="Upload an image to generate a 3D model (.glb)",
inference_triposg.py CHANGED
@@ -54,7 +54,7 @@ def run_triposg(
54
  num_inference_steps: int = 50,
55
  guidance_scale: float = 7.0,
56
  faces: int = -1,
57
- octree_depth: int = 9, # 👈 добавлено
58
  ) -> trimesh.Scene:
59
  print("[DEBUG] Preparing image...")
60
  img_pil = prepare_image(image_input, bg_color=np.array([1.0, 1.0, 1.0]), rmbg_net=rmbg_net)
@@ -65,7 +65,7 @@ def run_triposg(
65
  generator=torch.Generator(device=pipe.device).manual_seed(seed),
66
  num_inference_steps=num_inference_steps,
67
  guidance_scale=guidance_scale,
68
- flash_octree_depth=octree_depth, # 👈 добавлено
69
  ).samples[0]
70
 
71
  print("[DEBUG] TripoSG output keys:", type(outputs), outputs[0].shape, outputs[1].shape)
 
54
  num_inference_steps: int = 50,
55
  guidance_scale: float = 7.0,
56
  faces: int = -1,
57
+ # octree_depth: int = 9, # 👈 добавлено
58
  ) -> trimesh.Scene:
59
  print("[DEBUG] Preparing image...")
60
  img_pil = prepare_image(image_input, bg_color=np.array([1.0, 1.0, 1.0]), rmbg_net=rmbg_net)
 
65
  generator=torch.Generator(device=pipe.device).manual_seed(seed),
66
  num_inference_steps=num_inference_steps,
67
  guidance_scale=guidance_scale,
68
+ # flash_octree_depth=octree_depth, # 👈 добавлено
69
  ).samples[0]
70
 
71
  print("[DEBUG] TripoSG output keys:", type(outputs), outputs[0].shape, outputs[1].shape)