Spaces:
Paused
Paused
try zerogpu via spaces
Browse files- .gitignore +1 -0
- app.py +76 -68
- 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 |
-
|
| 14 |
-
|
| 15 |
-
'''
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
model = Model()
|
| 20 |
|
| 21 |
-
with gr.Blocks(css='style.css') as demo:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 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
|