Spaces:
Running
on
Zero
Running
on
Zero
Update hg_app.py
Browse files
hg_app.py
CHANGED
@@ -115,7 +115,11 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
|
|
115 |
{iframe_tag}
|
116 |
</div>
|
117 |
"""
|
118 |
-
|
|
|
|
|
|
|
|
|
119 |
|
120 |
@spaces.GPU(duration=100)
|
121 |
def _gen_shape(
|
@@ -181,6 +185,7 @@ def _gen_shape(
|
|
181 |
torch.cuda.empty_cache()
|
182 |
return mesh, save_folder, image
|
183 |
|
|
|
184 |
@spaces.GPU(duration=150)
|
185 |
def generation_all(
|
186 |
caption: str,
|
@@ -205,6 +210,8 @@ def generation_all(
|
|
205 |
path = export_mesh(mesh, save_folder, textured=False)
|
206 |
model_viewer_html = build_model_viewer_html(save_folder, height=596, width=700)
|
207 |
|
|
|
|
|
208 |
textured_mesh = texgen_worker(mesh, image)
|
209 |
path_textured = export_mesh(textured_mesh, save_folder, textured=True)
|
210 |
model_viewer_html_textured = build_model_viewer_html(save_folder, height=596, width=700, textured=True)
|
|
|
115 |
{iframe_tag}
|
116 |
</div>
|
117 |
"""
|
118 |
+
def get_texgen_worker():
|
119 |
+
if not hasattr(get_texgen_worker, 'worker'):
|
120 |
+
from hy3dgen.texgen import Hunyuan3DPaintPipeline
|
121 |
+
get_texgen_worker.worker = Hunyuan3DPaintPipeline.from_pretrained('tencent/Hunyuan3D-2')
|
122 |
+
return get_texgen_worker.worker
|
123 |
|
124 |
@spaces.GPU(duration=100)
|
125 |
def _gen_shape(
|
|
|
185 |
torch.cuda.empty_cache()
|
186 |
return mesh, save_folder, image
|
187 |
|
188 |
+
|
189 |
@spaces.GPU(duration=150)
|
190 |
def generation_all(
|
191 |
caption: str,
|
|
|
210 |
path = export_mesh(mesh, save_folder, textured=False)
|
211 |
model_viewer_html = build_model_viewer_html(save_folder, height=596, width=700)
|
212 |
|
213 |
+
# Initialize texgen_worker within the function
|
214 |
+
texgen_worker = get_texgen_worker()
|
215 |
textured_mesh = texgen_worker(mesh, image)
|
216 |
path_textured = export_mesh(textured_mesh, save_folder, textured=True)
|
217 |
model_viewer_html_textured = build_model_viewer_html(save_folder, height=596, width=700, textured=True)
|