radames HF staff commited on
Commit
ed9eac7
β€’
1 Parent(s): 5583e7a
.gitattributes CHANGED
@@ -25,3 +25,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.glb filter=lfs diff=lfs merge=lfs -text
PIFu/spaces.py CHANGED
@@ -21,6 +21,9 @@ from apps.crop_img import process_img
21
  from apps.eval import Evaluator
22
  from types import SimpleNamespace
23
  import trimesh
 
 
 
24
 
25
  print(
26
  "torch: ", torch.__version__,
@@ -89,12 +92,12 @@ def process(img_path):
89
  print("Evaluating via PIFu", time)
90
  evaluator.eval(data, True)
91
  print("Success Evaluating via PIFu", datetime.now() - time)
92
- result_path = f'{opts.results_path}/{opts.name}/result_{img_name}'
93
  except Exception as e:
94
  print("Error evaluating via PIFu", e)
95
 
96
  try:
97
- mesh = trimesh.load(result_path + '.obj')\
98
  # flip mesh
99
  mesh.apply_transform([[1, 0, 0, 0],
100
  [0, 1, 0, 0],
@@ -102,16 +105,16 @@ def process(img_path):
102
  [0, 0, 0, 1]])
103
  mesh.export(file_obj=result_path + '.glb')
104
  result_gltf = result_path + '.glb'
105
- return result_gltf
106
 
107
  except Exception as e:
108
  print("error generating MESH", e)
109
 
110
 
111
- examples = [["./examples/" + img] for img in sorted(os.listdir("./examples/"))]
112
  description = '''
113
  # PIFu Clothed Human Digitization
114
- # PIFu: Pixel-Aligned Implicit Function for High-Resolution Clothed Human Digitization
115
  <base target="_blank">
116
 
117
  This is a demo for <a href="https://github.com/shunsukesaito/PIFu" target="_blank"> PIFu model </a>.
@@ -123,14 +126,14 @@ The pre-trained model has the following warning:
123
  <details>
124
  <summary>More</summary>
125
 
126
- # Image Credits
127
 
128
  * Julien and Clem
129
  * [StyleGAN Humans](https://huggingface.co/spaces/hysts/StyleGAN-Human)
130
  * [Renderpeople: Dennis](https://renderpeople.com)
131
 
132
 
133
- # More
134
  * https://phorhum.github.io/
135
  * https://github.com/yuliangxiu/icon
136
  * https://shunsukesaito.github.io/PIFuHD/
@@ -141,14 +144,15 @@ The pre-trained model has the following warning:
141
  iface = gr.Interface(
142
  fn=process,
143
  description=description,
144
- inputs=gr.Image(type="filepath", label="Input Image"),
145
- outputs=gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model"),
 
 
 
 
146
  examples=examples,
147
  allow_flagging="never",
148
- cache_examples=True
149
-
150
-
151
  )
152
 
153
  if __name__ == "__main__":
154
- iface.launch(debug=True, enable_queue=False)
21
  from apps.eval import Evaluator
22
  from types import SimpleNamespace
23
  import trimesh
24
+ import glob
25
+
26
+ os.environ["CUDA_VISIBLE_DEVICES"]="0"
27
 
28
  print(
29
  "torch: ", torch.__version__,
92
  print("Evaluating via PIFu", time)
93
  evaluator.eval(data, True)
94
  print("Success Evaluating via PIFu", datetime.now() - time)
95
+ result_path = f'./{opts.results_path}/{opts.name}/result_{img_name}'
96
  except Exception as e:
97
  print("Error evaluating via PIFu", e)
98
 
99
  try:
100
+ mesh = trimesh.load(result_path + '.obj')
101
  # flip mesh
102
  mesh.apply_transform([[1, 0, 0, 0],
103
  [0, 1, 0, 0],
105
  [0, 0, 0, 1]])
106
  mesh.export(file_obj=result_path + '.glb')
107
  result_gltf = result_path + '.glb'
108
+ return [result_gltf, result_gltf]
109
 
110
  except Exception as e:
111
  print("error generating MESH", e)
112
 
113
 
114
+ examples = sorted(glob.glob('examples/*.png'))
115
  description = '''
116
  # PIFu Clothed Human Digitization
117
+ ### PIFu: Pixel-Aligned Implicit Function for High-Resolution Clothed Human Digitization
118
  <base target="_blank">
119
 
120
  This is a demo for <a href="https://github.com/shunsukesaito/PIFu" target="_blank"> PIFu model </a>.
126
  <details>
127
  <summary>More</summary>
128
 
129
+ #### Image Credits
130
 
131
  * Julien and Clem
132
  * [StyleGAN Humans](https://huggingface.co/spaces/hysts/StyleGAN-Human)
133
  * [Renderpeople: Dennis](https://renderpeople.com)
134
 
135
 
136
+ #### More
137
  * https://phorhum.github.io/
138
  * https://github.com/yuliangxiu/icon
139
  * https://shunsukesaito.github.io/PIFuHD/
144
  iface = gr.Interface(
145
  fn=process,
146
  description=description,
147
+ inputs=gr.inputs.Image(type="filepath", label="Input Image"),
148
+ outputs=[
149
+ gr.outputs.Image3D(
150
+ clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model"),
151
+ gr.outputs.File(label="Download 3D Model")
152
+ ],
153
  examples=examples,
154
  allow_flagging="never",
 
 
 
155
  )
156
 
157
  if __name__ == "__main__":
158
+ iface.launch(debug=True, enable_queue=False, cache_examples=True)
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: πŸ§πŸ½β€β™€οΈπŸ§πŸ»πŸ§πŸ½β€β™‚οΈΒ 
4
  colorFrom: pink
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 2.9.0b8
8
  app_file: ./PIFu/spaces.py
9
  pinned: false
10
  python_version: 3.7.13
4
  colorFrom: pink
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 2.9.4
8
  app_file: ./PIFu/spaces.py
9
  pinned: false
10
  python_version: 3.7.13
examples/9.jpg DELETED
Binary file (97.1 kB)
gradio_cached_examples/{output β†’ 3D Model}/0.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:51c42092c3a6aa9474e2730abe589613799b17e4690ca7a5828793bff5a9e02c
3
- size 1505632
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:397d5092f3fd8c296124fa8359e17ae1c30cd87298c6b1a851e8fa863b6bb2d7
3
+ size 1448964
gradio_cached_examples/{output β†’ 3D Model}/1.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c35e9b0c26076b03ceceafebca102f29e8a7a5639077e8d136a09462780e7fc0
3
- size 1738476
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5940a0fa4905caebac714394ffb5a5576808bf36452fd15f0a04e0754ec3222e
3
+ size 1606488
gradio_cached_examples/{output β†’ 3D Model}/2.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:936580bb641571952fe92a24d83e6497d590f0f35648d58ab4f0e08f40799f35
3
- size 1655296
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb8d49f5ef0768ee81f1c9d3e141432854221bf5270f5bb46c490c43a73e5593
3
+ size 1517748
gradio_cached_examples/{output β†’ 3D Model}/3.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fb0656e2ae1ed068edc5b0ba2d07a1f4f7facc29b17f13ad4d99deadafd5ce89
3
- size 1634868
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f35f041c03e273ae7a1189e7a3148a5c376dd222ae9d16842fa9716784b6eb06
3
+ size 1510776
gradio_cached_examples/{output β†’ 3D Model}/4.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5e5429c65a47534d321b4092f0488dfe7ab97b7dd50282abf63973fbb8989ff0
3
- size 1776568
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4f5170735644099ab38ab5760cdde10cd08cade2ff0d2f1e2c66562d6c6f5b0
3
+ size 1724844
gradio_cached_examples/{output β†’ 3D Model}/5.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a52329b5671d2156af19696bddcc438b564c0182b12d052f29cd3684dbaaed38
3
- size 1739900
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56b65a8340c53c9fbb1f8dddc9176035a64212649e4e638beb09b6628fbf51fe
3
+ size 1706220
gradio_cached_examples/{output β†’ 3D Model}/6.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:82891044af3d1e2bcdd8aa89c3f255824e666ad49db966c8b15807ca22eabb39
3
- size 1623368
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de5d0d9e44e345e0b1a09d7248a9630b8e087c287aafb94c6ecd7659da87687c
3
+ size 1589920
gradio_cached_examples/{output β†’ 3D Model}/7.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bc5d8e2a3470ed1b41c76b115270a38fa29553c88f25e49dda2658a1d5d8d591
3
- size 2045228
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:400af9c0925b80dc8f0e1e561cfca4e09e0e6dfd990d0ba30880f52f6d220870
3
+ size 1923292
gradio_cached_examples/{output β†’ 3D Model}/8.glb RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:938197e4107f156d5a407ff68846e56ea268cf0bb18cf575bce21cc4f67b11cf
3
- size 1921788
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89f4cb56c84a1cf7e4cfb31ef0e3bd0b0dd62ea2f71cd70a80f4b8f39ebe3c0c
3
+ size 2059096
gradio_cached_examples/Download 3D Model/0.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:397d5092f3fd8c296124fa8359e17ae1c30cd87298c6b1a851e8fa863b6bb2d7
3
+ size 1448964
gradio_cached_examples/Download 3D Model/1.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5940a0fa4905caebac714394ffb5a5576808bf36452fd15f0a04e0754ec3222e
3
+ size 1606488
gradio_cached_examples/Download 3D Model/2.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb8d49f5ef0768ee81f1c9d3e141432854221bf5270f5bb46c490c43a73e5593
3
+ size 1517748
gradio_cached_examples/Download 3D Model/3.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f35f041c03e273ae7a1189e7a3148a5c376dd222ae9d16842fa9716784b6eb06
3
+ size 1510776
gradio_cached_examples/Download 3D Model/4.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4f5170735644099ab38ab5760cdde10cd08cade2ff0d2f1e2c66562d6c6f5b0
3
+ size 1724844
gradio_cached_examples/Download 3D Model/5.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56b65a8340c53c9fbb1f8dddc9176035a64212649e4e638beb09b6628fbf51fe
3
+ size 1706220
gradio_cached_examples/Download 3D Model/6.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de5d0d9e44e345e0b1a09d7248a9630b8e087c287aafb94c6ecd7659da87687c
3
+ size 1589920
gradio_cached_examples/Download 3D Model/7.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:400af9c0925b80dc8f0e1e561cfca4e09e0e6dfd990d0ba30880f52f6d220870
3
+ size 1923292
gradio_cached_examples/Download 3D Model/8.glb ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89f4cb56c84a1cf7e4cfb31ef0e3bd0b0dd62ea2f71cd70a80f4b8f39ebe3c0c
3
+ size 2059096
gradio_cached_examples/log.csv CHANGED
@@ -1,11 +1,10 @@
1
- 'output','flag','username','timestamp'
2
- 'output/0.glb','','','2022-04-26 14:01:10.698644'
3
- 'output/1.glb','','','2022-04-26 14:01:09.394488'
4
- 'output/2.glb','','','2022-04-26 14:01:08.760863'
5
- 'output/3.glb','','','2022-04-26 14:01:07.727793'
6
- 'output/4.glb','','','2022-04-26 14:01:06.102981'
7
- 'output/5.glb','','','2022-04-26 14:01:05.406731'
8
- 'output/6.glb','','','2022-04-26 14:01:04.145110'
9
- 'output/7.glb','','','2022-04-26 14:01:03.142050'
10
- 'output/8.glb','','','2022-04-26 14:01:02.142050'
11
- 'output/9.glb','','','2022-04-26 14:01:01.142050'
1
+ '3D Model','Download 3D Model'
2
+ '3D Model/0.glb','Download 3D Model/0.glb'
3
+ '3D Model/1.glb','Download 3D Model/1.glb'
4
+ '3D Model/2.glb','Download 3D Model/2.glb'
5
+ '3D Model/3.glb','Download 3D Model/3.glb'
6
+ '3D Model/4.glb','Download 3D Model/4.glb'
7
+ '3D Model/5.glb','Download 3D Model/5.glb'
8
+ '3D Model/6.glb','Download 3D Model/6.glb'
9
+ '3D Model/7.glb','Download 3D Model/7.glb'
10
+ '3D Model/8.glb','Download 3D Model/8.glb'
 
gradio_cached_examples/output/.gitattributes DELETED
File without changes
gradio_cached_examples/output/9.glb DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:751843708e0f2ce1ce063afd1c0f7e26bc39826e922a77176acb6c36c518242c
3
- size 1808476
 
 
 
requirements.txt CHANGED
@@ -21,4 +21,5 @@ torchvision==0.5.0
21
  trimesh==3.5.23
22
  tqdm==4.64.0
23
  paddlehub
24
- paddlepaddle
 
21
  trimesh==3.5.23
22
  tqdm==4.64.0
23
  paddlehub
24
+ paddlepaddle
25
+ glob2