Files changed (1) hide show
  1. app.py +0 -158
app.py CHANGED
@@ -1,158 +0,0 @@
1
- # install
2
-
3
-
4
- import glob
5
- import gradio as gr
6
- import os
7
- import numpy as np
8
-
9
- import subprocess
10
-
11
- if os.getenv('SYSTEM') == 'spaces':
12
- subprocess.run('pip install pyembree'.split())
13
- subprocess.run(
14
- 'pip install git+https://github.com/YuliangXiu/rembg.git@hf'.split())
15
- subprocess.run(
16
- 'pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html'.split())
17
- subprocess.run(
18
- 'pip install https://download.is.tue.mpg.de/icon/HF/kaolin-0.11.0-cp38-cp38-linux_x86_64.whl'.split())
19
- subprocess.run(
20
- 'pip install https://download.is.tue.mpg.de/icon/HF/pytorch3d-0.7.0-cp38-cp38-linux_x86_64.whl'.split())
21
- subprocess.run(
22
- 'pip install git+https://github.com/YuliangXiu/neural_voxelization_layer.git'.split())
23
-
24
- from apps.infer import generate_model
25
-
26
- # running
27
-
28
- description = '''
29
- # ICON Clothed Human Digitization
30
- ### ICON: Implicit Clothed humans Obtained from Normals (CVPR 2022)
31
-
32
- <table>
33
- <th>
34
- <ul>
35
- <li><strong>Homepage</strong> <a href="http://icon.is.tue.mpg.de">icon.is.tue.mpg.de</a></li>
36
- <li><strong>Code</strong> <a href="https://github.com/YuliangXiu/ICON">YuliangXiu/ICON</a></li>
37
- <li><strong>Paper</strong> <a href="https://arxiv.org/abs/2112.09127">arXiv</a>, <a href="https://readpaper.com/paper/4569785684533977089">ReadPaper</a></li>
38
- <li><strong>Chatroom</strong> <a href="https://discord.gg/Vqa7KBGRyk">Discord</a></li>
39
- <li><strong>Colab Notebook</strong> <a href="https://colab.research.google.com/drive/1-AWeWhPvCTBX0KfMtgtMk10uPU05ihoA?usp=sharing">Google Colab</a></li>
40
- </ul>
41
- <a href="https://twitter.com/yuliangxiu"><img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/yuliangxiu?style=social"></a>
42
- <iframe src="https://ghbtns.com/github-btn.html?user=yuliangxiu&repo=ICON&type=star&count=true&v=2&size=small" frameborder="0" scrolling="0" width="100" height="20"></iframe>
43
- <a href="https://youtu.be/hZd6AYin2DE"><img alt="YouTube Video Views" src="https://img.shields.io/youtube/views/hZd6AYin2DE?style=social"></a>
44
- </th>
45
- <th>
46
- <iframe width="560" height="315" src="https://www.youtube.com/embed/hZd6AYin2DE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
47
- </th>
48
- </table>
49
-
50
- <h4> The reconstruction + refinement + video take about 200 seconds for single image. <span style="color:red"> If ERROR, try "Submit Image" again.</span></h4>
51
-
52
- <details>
53
-
54
- <summary>More</summary>
55
-
56
- #### Citation
57
- ```
58
- @inproceedings{xiu2022icon,
59
- title = {{ICON}: {I}mplicit {C}lothed humans {O}btained from {N}ormals},
60
- author = {Xiu, Yuliang and Yang, Jinlong and Tzionas, Dimitrios and Black, Michael J.},
61
- booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
62
- month = {June},
63
- year = {2022},
64
- pages = {13296-13306}
65
- }
66
- ```
67
-
68
- #### Acknowledgments:
69
-
70
- - [StyleGAN-Human, ECCV 2022](https://stylegan-human.github.io/)
71
- - [nagolinc/styleGanHuman_and_PIFu](https://huggingface.co/spaces/nagolinc/styleGanHuman_and_PIFu)
72
- - [radames/PIFu-Clothed-Human-Digitization](https://huggingface.co/spaces/radames/PIFu-Clothed-Human-Digitization)
73
-
74
- #### Image Credits
75
-
76
- * [Pinterest](https://www.pinterest.com/search/pins/?q=parkour&rs=sitelinks_searchbox)
77
-
78
- #### Related works
79
-
80
- * [ICON @ MPI](https://icon.is.tue.mpg.de/)
81
- * [MonoPort @ USC](https://xiuyuliang.cn/monoport)
82
- * [Phorhum @ Google](https://phorhum.github.io/)
83
- * [PIFuHD @ Meta](https://shunsukesaito.github.io/PIFuHD/)
84
- * [PaMIR @ Tsinghua](http://www.liuyebin.com/pamir/pamir.html)
85
-
86
- </details>
87
- '''
88
-
89
-
90
- def generate_image(seed, psi):
91
- iface = gr.Interface.load("spaces/hysts/StyleGAN-Human")
92
- img = iface(seed, psi)
93
- return img
94
-
95
-
96
- model_types = ['ICON', 'PIFu', 'PaMIR']
97
- examples_names = glob.glob('examples/*.png')
98
- examples_types = np.random.choice(
99
- model_types, len(examples_names), p=[0.6, 0.2, 0.2])
100
-
101
- examples = [list(item) for item in zip(examples_names, examples_types)]
102
-
103
- with gr.Blocks() as demo:
104
- gr.Markdown(description)
105
-
106
- out_lst = []
107
- with gr.Row():
108
- with gr.Column():
109
- with gr.Row():
110
- with gr.Column():
111
- seed = gr.inputs.Slider(
112
- 0, 1000, step=1, default=0, label='Seed (For Image Generation)')
113
- psi = gr.inputs.Slider(
114
- 0, 2, step=0.05, default=0.7, label='Truncation psi (For Image Generation)')
115
- radio_choice = gr.Radio(
116
- model_types, label='Method (For Reconstruction)', value='icon-filter')
117
- inp = gr.Image(type="filepath", label="Input Image")
118
- with gr.Row():
119
- btn_sample = gr.Button("Generate Image")
120
- btn_submit = gr.Button("Submit Image")
121
-
122
- gr.Examples(examples=examples,
123
- inputs=[inp, radio_choice],
124
- cache_examples=False,
125
- fn=generate_model,
126
- outputs=out_lst)
127
-
128
- out_vid = gr.Video(
129
- label="Image + Normal + SMPL Body + Clothed Human")
130
- out_vid_download = gr.File(
131
- label="Download Video, welcome share on Twitter with #ICON")
132
-
133
- with gr.Column():
134
- overlap_inp = gr.Image(
135
- type="filepath", label="Image Normal Overlap")
136
- out_final = gr.Model3D(
137
- clear_color=[0.0, 0.0, 0.0, 0.0], label="Clothed human")
138
- out_final_download = gr.File(
139
- label="Download clothed human mesh")
140
- out_smpl = gr.Model3D(
141
- clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL body")
142
- out_smpl_download = gr.File(label="Download SMPL body mesh")
143
- out_smpl_npy_download = gr.File(label="Download SMPL params")
144
-
145
- out_lst = [out_smpl, out_smpl_download, out_smpl_npy_download,
146
- out_final, out_final_download, out_vid, out_vid_download, overlap_inp]
147
-
148
- btn_submit.click(fn=generate_model, inputs=[
149
- inp, radio_choice], outputs=out_lst)
150
- btn_sample.click(fn=generate_image, inputs=[seed, psi], outputs=inp)
151
-
152
- if __name__ == "__main__":
153
-
154
- # demo.launch(debug=False, enable_queue=False,
155
- # auth=(os.environ['USER'], os.environ['PASSWORD']),
156
- # auth_message="Register at icon.is.tue.mpg.de to get HuggingFace username and password.")
157
-
158
- demo.launch(debug=True, enable_queue=True)