perler commited on
Commit
4e10b60
1 Parent(s): fb35ed7

try zerogpu via spaces

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +76 -68
  3. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea/
app.py CHANGED
@@ -4,80 +4,88 @@ from __future__ import annotations
4
 
5
  import os
6
 
 
7
  import gradio as gr
8
 
9
  from model import Model
10
 
11
- DESCRIPTION = '''# [TEXTure](https://github.com/TEXTurePaper/TEXTurePaper)
12
 
13
- - This demo only accepts as input `.obj` files with less than 100,000 faces.
14
- - Inference takes about 10 minutes on a T4 GPU.
15
- '''
16
- if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
17
- 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>'
 
 
 
 
18
 
19
- model = Model()
20
 
21
- with gr.Blocks(css='style.css') as demo:
22
- gr.Markdown(DESCRIPTION)
23
- with gr.Row():
24
- with gr.Column():
25
- input_shape = gr.Model3D(label='Input 3D mesh')
26
- text = gr.Text(label='Text')
27
- seed = gr.Slider(label='Seed',
28
- minimum=0,
29
- maximum=100000,
30
- value=3,
31
- step=1)
32
- guidance_scale = gr.Slider(label='Guidance scale',
33
- minimum=0,
34
- maximum=50,
35
- value=7.5,
36
- step=0.1)
37
- run_button = gr.Button('Run')
38
- with gr.Column():
39
- progress_text = gr.Text(label='Progress')
40
- with gr.Tabs():
41
- with gr.TabItem(label='Images from each viewpoint'):
42
- viewpoint_images = gr.Gallery(show_label=False).style(
43
- columns=4, height='auto')
44
- with gr.TabItem(label='Result 3D model'):
45
- result_3d_model = gr.Model3D(show_label=False)
46
- with gr.TabItem(label='Output mesh file'):
47
- output_file = gr.File(show_label=False)
48
- with gr.Row():
49
- examples = [
50
- ['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
51
- ['shapes/dragon2.obj', 'a photo of a dragon', 0, 7.5],
52
- ['shapes/eagle.obj', 'a photo of an eagle', 0, 7.5],
53
- ['shapes/napoleon.obj', 'a photo of Napoleon Bonaparte', 3, 7.5],
54
- ['shapes/nascar.obj', 'A next gen nascar', 2, 10],
55
- ]
56
- gr.Examples(examples=examples,
57
- inputs=[
58
- input_shape,
59
- text,
60
- seed,
61
- guidance_scale,
62
- ],
63
- outputs=[
64
- result_3d_model,
65
- output_file,
66
- ],
67
- cache_examples=False)
68
 
69
- run_button.click(fn=model.run,
70
- inputs=[
71
- input_shape,
72
- text,
73
- seed,
74
- guidance_scale,
75
- ],
76
- outputs=[
77
- viewpoint_images,
78
- result_3d_model,
79
- output_file,
80
- progress_text,
81
- ])
82
 
83
- demo.queue(max_size=5).launch(debug=True)
 
 
 
 
 
4
 
5
  import os
6
 
7
+ import spaces
8
  import gradio as gr
9
 
10
  from model import Model
11
 
 
12
 
13
+ @spaces.GPU
14
+ def main():
15
+ DESCRIPTION = '''# [TEXTure](https://github.com/TEXTurePaper/TEXTurePaper)
16
+
17
+ - This demo only accepts as input `.obj` files with less than 100,000 faces.
18
+ - Inference takes about 10 minutes on a T4 GPU.
19
+ '''
20
+ if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
21
+ 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>'
22
 
23
+ model = Model()
24
 
25
+ with gr.Blocks(css='style.css') as demo:
26
+ gr.Markdown(DESCRIPTION)
27
+ with gr.Row():
28
+ with gr.Column():
29
+ input_shape = gr.Model3D(label='Input 3D mesh')
30
+ text = gr.Text(label='Text')
31
+ seed = gr.Slider(label='Seed',
32
+ minimum=0,
33
+ maximum=100000,
34
+ value=3,
35
+ step=1)
36
+ guidance_scale = gr.Slider(label='Guidance scale',
37
+ minimum=0,
38
+ maximum=50,
39
+ value=7.5,
40
+ step=0.1)
41
+ run_button = gr.Button('Run')
42
+ with gr.Column():
43
+ progress_text = gr.Text(label='Progress')
44
+ with gr.Tabs():
45
+ with gr.TabItem(label='Images from each viewpoint'):
46
+ viewpoint_images = gr.Gallery(show_label=False).style(
47
+ columns=4, height='auto')
48
+ with gr.TabItem(label='Result 3D model'):
49
+ result_3d_model = gr.Model3D(show_label=False)
50
+ with gr.TabItem(label='Output mesh file'):
51
+ output_file = gr.File(show_label=False)
52
+ with gr.Row():
53
+ examples = [
54
+ ['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
55
+ ['shapes/dragon2.obj', 'a photo of a dragon', 0, 7.5],
56
+ ['shapes/eagle.obj', 'a photo of an eagle', 0, 7.5],
57
+ ['shapes/napoleon.obj', 'a photo of Napoleon Bonaparte', 3, 7.5],
58
+ ['shapes/nascar.obj', 'A next gen nascar', 2, 10],
59
+ ]
60
+ gr.Examples(examples=examples,
61
+ inputs=[
62
+ input_shape,
63
+ text,
64
+ seed,
65
+ guidance_scale,
66
+ ],
67
+ outputs=[
68
+ result_3d_model,
69
+ output_file,
70
+ ],
71
+ cache_examples=False)
72
 
73
+ run_button.click(fn=model.run,
74
+ inputs=[
75
+ input_shape,
76
+ text,
77
+ seed,
78
+ guidance_scale,
79
+ ],
80
+ outputs=[
81
+ viewpoint_images,
82
+ result_3d_model,
83
+ output_file,
84
+ progress_text,
85
+ ])
86
 
87
+ demo.queue(max_size=5).launch(debug=True)
88
+
89
+
90
+ if __name__ == '__main__':
91
+ main()
requirements.txt CHANGED
@@ -14,3 +14,4 @@ tqdm==4.65.0
14
  transformers==4.29.1
15
  trimesh==3.21.6
16
  xatlas==0.0.7
 
 
14
  transformers==4.29.1
15
  trimesh==3.21.6
16
  xatlas==0.0.7
17
+ spaces==0.23.2