perler commited on
Commit
18eb0a8
1 Parent(s): f3b2cb8

try extra function again

Browse files
Files changed (2) hide show
  1. app.py +13 -5
  2. model.py +1 -5
app.py CHANGED
@@ -5,8 +5,14 @@ from __future__ import annotations
5
  import os
6
 
7
  import gradio as gr
 
8
 
9
- from model import Model
 
 
 
 
 
10
 
11
 
12
  def main():
@@ -16,9 +22,11 @@ def main():
16
  - Inference takes about 10 minutes on a T4 GPU.
17
  '''
18
  if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
19
- DESCRIPTION += f'\n<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
20
-
21
- model = Model()
 
 
22
 
23
  with gr.Blocks(css='style.css') as demo:
24
  gr.Markdown(DESCRIPTION)
@@ -67,7 +75,7 @@ def main():
67
  ],
68
  cache_examples=False)
69
 
70
- run_button.click(fn=model.run,
71
  inputs=[
72
  input_shape,
73
  text,
 
5
  import os
6
 
7
  import gradio as gr
8
+ import spaces
9
 
10
+
11
+ @spaces.GPU
12
+ def run_on_gpu(input_shape, text, seed, guidance_scale):
13
+ from model import Model
14
+ model = Model()
15
+ return model.run(shape_path=input_shape, text=text, seed=seed, guidance_scale=guidance_scale)
16
 
17
 
18
  def main():
 
22
  - Inference takes about 10 minutes on a T4 GPU.
23
  '''
24
  if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
25
+ DESCRIPTION += (f'\n<p>For faster inference without waiting in queue, '
26
+ f'you may duplicate the space and upgrade to GPU in settings. '
27
+ f'<a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true">'
28
+ f'<img style="display: inline; margin-top: 0em; margin-bottom: 0em" '
29
+ f'src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>')
30
 
31
  with gr.Blocks(css='style.css') as demo:
32
  gr.Markdown(DESCRIPTION)
 
75
  ],
76
  cache_examples=False)
77
 
78
+ run_button.click(fn=run_on_gpu,
79
  inputs=[
80
  input_shape,
81
  text,
model.py CHANGED
@@ -9,7 +9,6 @@ from typing import Generator, Optional
9
 
10
  import gradio as gr
11
  import trimesh
12
- import spaces
13
 
14
  sys.path.append('TEXTurePaper')
15
 
@@ -21,7 +20,6 @@ class Model:
21
  def __init__(self):
22
  self.max_num_faces = 100000
23
 
24
- @spaces.GPU
25
  def load_config(self, shape_path: str, text: str, seed: int,
26
  guidance_scale: float) -> TrainConfig:
27
  text += ', {} view'
@@ -52,11 +50,9 @@ class Model:
52
  subprocess.run(shlex.split(f'zip -r {out_path} {mesh_dir}'))
53
  return out_path
54
 
55
- @spaces.GPU
56
  def run(
57
  self, shape_path: str, text: str, seed: int, guidance_scale: float
58
- ) -> Generator[tuple[list[str], Optional[str], Optional[str], str], None,
59
- None]:
60
  if not shape_path.endswith('.obj'):
61
  raise gr.Error('The input file is not .obj file.')
62
  if not self.check_num_faces(shape_path):
 
9
 
10
  import gradio as gr
11
  import trimesh
 
12
 
13
  sys.path.append('TEXTurePaper')
14
 
 
20
  def __init__(self):
21
  self.max_num_faces = 100000
22
 
 
23
  def load_config(self, shape_path: str, text: str, seed: int,
24
  guidance_scale: float) -> TrainConfig:
25
  text += ', {} view'
 
50
  subprocess.run(shlex.split(f'zip -r {out_path} {mesh_dir}'))
51
  return out_path
52
 
 
53
  def run(
54
  self, shape_path: str, text: str, seed: int, guidance_scale: float
55
+ ) -> Generator[tuple[list[str], Optional[str], Optional[str], str], None, None]:
 
56
  if not shape_path.endswith('.obj'):
57
  raise gr.Error('The input file is not .obj file.')
58
  if not self.check_num_faces(shape_path):