NicolasG2523 commited on
Commit
9603647
·
verified ·
1 Parent(s): 6cb3ee9

Upload 2 files

Browse files
Files changed (2) hide show
  1. gradio_app.py +18 -9
  2. pre-requirements.txt +1 -0
gradio_app.py CHANGED
@@ -32,18 +32,25 @@ from hy3dgen.shapegen.utils import logger
32
  MAX_SEED = 1e7
33
 
34
  import spaces
35
- import subprocess
36
- import sys
37
- import shlex
38
- print("cd /home/user/app/hy3dgen/texgen/differentiable_renderer/ && bash compile_mesh_painter.sh")
39
- os.system("cd /home/user/app/hy3dgen/texgen/differentiable_renderer/ && bash compile_mesh_painter.sh")
40
- print('install custom')
41
- subprocess.run(shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"), check=True)
42
 
 
 
 
 
 
 
 
 
 
 
 
43
  @spaces.GPU
44
  def my_gpu_function():
45
  return "my_gpu_function processed on GPU"
46
 
 
 
 
47
  def get_example_img_list():
48
  print('Loading example img list ...')
49
  return sorted(glob('./assets/example_images/**/*.png', recursive=True))
@@ -664,7 +671,7 @@ if __name__ == '__main__':
664
  parser.add_argument("--model_path", type=str, default='tencent/Hunyuan3D-2mv')
665
  parser.add_argument("--subfolder", type=str, default='hunyuan3d-dit-v2-mv-turbo')
666
  parser.add_argument("--texgen_model_path", type=str, default='tencent/Hunyuan3D-2')
667
- #parser.add_argument('--port', type=int, default=7860)
668
  parser.add_argument('--host', type=str, default='0.0.0.0')
669
  parser.add_argument('--device', type=str, default='cuda')
670
  parser.add_argument('--mc_algo', type=str, default='mc')
@@ -707,7 +714,9 @@ if __name__ == '__main__':
707
  </div>
708
  """
709
 
710
- my_gpu_function = my_gpu_function()
 
 
711
  example_is = get_example_img_list()
712
  example_ts = get_example_txt_list()
713
  example_mvs = get_example_mv_list()
 
32
  MAX_SEED = 1e7
33
 
34
  import spaces
 
 
 
 
 
 
 
35
 
36
+ if True:
37
+ import os
38
+ import subprocess
39
+ import sys
40
+ import shlex
41
+ print("cd /home/user/app/hy3dgen/texgen/differentiable_renderer/ && bash compile_mesh_painter.sh")
42
+ os.system("cd /home/user/app/hy3dgen/texgen/differentiable_renderer/ && bash compile_mesh_painter.sh")
43
+ print('install custom')
44
+ subprocess.run(shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"), check=True)
45
+
46
+ # 2 functions just for GPU usage at startup
47
  @spaces.GPU
48
  def my_gpu_function():
49
  return "my_gpu_function processed on GPU"
50
 
51
+ def call_gpu_function():
52
+ return my_gpu_function() # Only called on Gradio event
53
+
54
  def get_example_img_list():
55
  print('Loading example img list ...')
56
  return sorted(glob('./assets/example_images/**/*.png', recursive=True))
 
671
  parser.add_argument("--model_path", type=str, default='tencent/Hunyuan3D-2mv')
672
  parser.add_argument("--subfolder", type=str, default='hunyuan3d-dit-v2-mv-turbo')
673
  parser.add_argument("--texgen_model_path", type=str, default='tencent/Hunyuan3D-2')
674
+ parser.add_argument('--port', type=int, default="7860")
675
  parser.add_argument('--host', type=str, default='0.0.0.0')
676
  parser.add_argument('--device', type=str, default='cuda')
677
  parser.add_argument('--mc_algo', type=str, default='mc')
 
714
  </div>
715
  """
716
 
717
+ gpu_usage = gr.Interface(fn=call_gpu_function, inputs=[], outputs="text")
718
+ gpu_usage.launch()
719
+
720
  example_is = get_example_img_list()
721
  example_ts = get_example_txt_list()
722
  example_mvs = get_example_mv_list()
pre-requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pip install --upgrade pip