Spaces:
Sleeping
Sleeping
byeongjun-park
commited on
Commit
Β·
7355d35
1
Parent(s):
cc3abfa
HarmonyView update
Browse files
app.py
CHANGED
@@ -20,21 +20,16 @@ _DESCRIPTION = '''
|
|
20 |
<a style="display:inline-block; margin-left: .5em" href="https://arxiv.org/abs/2312.15980"><img src="https://img.shields.io/badge/2312.15980-f9f7f7?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAABMCAYAAADJPi9EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAa2SURBVHja3Zt7bBRFGMAXUCDGF4rY7m7bAwuhlggKStFgLBgFEkCIIRJEEoOBYHwRFYKilUgEReVNJEGCJJpehHI3M9vZvd3bUP1DjNhEIRQQsQgSHiJgQZ5dv7krWEvvdmZ7d7vHJN+ft/f99pv5XvOtJMFCqvoCUpTdIEeRLC+L9Ox5i3Q9LACaCeK0kXoSChVcD3C/tQPHpAEsquQ73IkUcEz2kcLCknyGW5MGjkljRFVL8xJOKyi4CwCOuQAeAkfTP1+tNxLkogvgEbDgffkJqKqvuMA5ifOpqg/5qWecRstNg7xoUTI1Fovdxg8oy2s5AP8CGeYHmGngeZaOL4I4LXLcpHg4149/GDz4xqgsb+UAbMKKUpkrqHA43MUyyJpWUK0EHeG2YKRXr7tB+QMcgGewLD+ebTDbtrtbBt7UPlhS4rV4IvcDI7J8P1OeA/AcAI7LHljN7aB8XTowJmZt9EFRD/o0SDMH4HlwMhMyDWZZSAHFf3YDs3RS49WDLuaAY3IJq+qzmQKLxXAZKN7oDoYbdV3v5elPqiSpMyiOuAEVZVqHXb1OhloUH+MA+ztO0cAO/RkrfyBE7OAEbAZvO8vzVtTRWFD6DAfY5biBM3PWiaL0a4lvXICwnV8WjmE6ntYmhqX2jjp5LbMZjCw/wbYeN6CizOa2GMVzQOlmHjB4Ceuyk6LJ8huccEmR5Xddg7O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obZ77LpGZ8TAIun+/iCKQoF71IxQDI3K2CCd+ARNvXg9sykBcnHAoCZG4u66hlDoQLe6QV4CRtFSxZQ+D0BwNO2jgdkzoGoah1nj3FVlSR19taTSYxI8QLut23U8dsgzqHulJNCQpcqBnpTALCuQ6NSYLHpmR5i42gZzuIdcrMMvMJbQlxe3jXxyZnLACl7ARm/FjPIDOY8ODtpM71sxwfcZpvBeUzKWmfNINM5AS+wO0Khh7dMqKccu4+qatarZjYAwDlgetzStHtEt+XedsBOQtU9XMrRgjg4KTnc5nr+dmqadit/4C4uLm8DuA9koJTj1TL7fI5nDL+qqoo/FLGAzL7dYT17PzvAcQONYSUQRxW/QMrHZVIyik0ZuQA2mzp+Ji8BW4YM3Mbzm9inaHkJCGfrUZZjujiYailfFwA8DHIy3acwUj4v9vUVa+SmgNsl5fuyDTKovW9/IAmfLV0Pi2UncA515kjYdrwC9i9rpuHiq3JwtAAAAABJRU5ErkJggg=="></a>
|
21 |
<a style="display:inline-block; margin-left: .5em" href='https://github.com/byeongjun-park/HarmonyView'><img src='https://img.shields.io/github/stars/byeongjun-park/HarmonyView?style=social' /></a>
|
22 |
</div>
|
23 |
-
Given a single-view image, HarmonyView is able to generate multiview-consistent images,
|
24 |
|
25 |
Procedure: </br>
|
26 |
-
**Step 1**. Upload an image
|
27 |
-
**Step 2**. Select
|
|
|
28 |
You may adjust the **Crop size** and **Elevation angle** to get a better result! <br>
|
29 |
To reconstruct a NeRF or a 3D mesh from the generated images, please refer to our [github repository](https://github.com/byeongjun-park/HarmonyView). <br>
|
30 |
We have heavily borrowed codes from [Syncdreamer](https://huggingface.co/spaces/liuyuan-pal/SyncDreamer), which is an our strong baseline.
|
31 |
'''
|
32 |
-
_USER_GUIDE0 = "Step1: Please upload an image in the block above (or choose an example shown in the left)."
|
33 |
-
# _USER_GUIDE1 = "Step1: Please select a **Crop size** and click **Crop it**."
|
34 |
-
_USER_GUIDE2 = "Step2: Please choose a **Elevation angle** and click **Run Generate**. The **Elevation angle** is the elevation of the Input image. This costs about 45s."
|
35 |
-
_USER_GUIDE3 = "Generated multiview images are shown below! (You may adjust the **Crop size** and **Elevation angle** to get a better result!)"
|
36 |
-
|
37 |
-
others = '''**Step 1**. Select "Crop size" and click "Crop it". ==> The foreground object is centered and resized. </br>'''
|
38 |
|
39 |
deployed = True
|
40 |
|
@@ -180,14 +175,16 @@ def run_demo():
|
|
180 |
|
181 |
# NOTE: Examples must match inputs
|
182 |
examples_full = [
|
183 |
-
['hf_demo/examples/
|
184 |
-
['hf_demo/examples/
|
185 |
-
['hf_demo/examples/
|
186 |
-
['hf_demo/examples/
|
187 |
-
['hf_demo/examples/
|
|
|
|
|
188 |
['hf_demo/examples/forest.png',30,200,"SAM output"],
|
|
|
189 |
['hf_demo/examples/teapot.png',20,200,"SAM output"],
|
190 |
-
['hf_demo/examples/basket.png',30,200,"SAM output"],
|
191 |
]
|
192 |
|
193 |
image_block = gr.Image(type='pil', image_mode='RGBA', height=256, label='Input image', tool=None, interactive=True)
|
@@ -216,7 +213,6 @@ def run_demo():
|
|
216 |
|
217 |
with gr.Column(scale=0.8):
|
218 |
image_block.render()
|
219 |
-
# guide_text = gr.Markdown(_USER_GUIDE0, visible=True)
|
220 |
crop_size.render()
|
221 |
fig0 = gr.Image(value=Image.open('assets/crop_size.jpg'), type='pil', image_mode='RGB', height=256, show_label=False, tool=None, interactive=False)
|
222 |
|
@@ -238,9 +234,7 @@ def run_demo():
|
|
238 |
|
239 |
output_block = gr.Image(type='pil', image_mode='RGB', label="Outputs of HarmonyView", height=256, interactive=False)
|
240 |
|
241 |
-
image_block.change(fn=partial(sam_predict, mask_predictor, removal), inputs=[image_block], outputs=[sam_block], queue=True)
|
242 |
-
.success(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
|
243 |
-
|
244 |
background_removal.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
|
245 |
crop_size.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
|
246 |
|
|
|
20 |
<a style="display:inline-block; margin-left: .5em" href="https://arxiv.org/abs/2312.15980"><img src="https://img.shields.io/badge/2312.15980-f9f7f7?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAABMCAYAAADJPi9EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAuIwAALiMBeKU/dgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAa2SURBVHja3Zt7bBRFGMAXUCDGF4rY7m7bAwuhlggKStFgLBgFEkCIIRJEEoOBYHwRFYKilUgEReVNJEGCJJpehHI3M9vZvd3bUP1DjNhEIRQQsQgSHiJgQZ5dv7krWEvvdmZ7d7vHJN+ft/f99pv5XvOtJMFCqvoCUpTdIEeRLC+L9Ox5i3Q9LACaCeK0kXoSChVcD3C/tQPHpAEsquQ73IkUcEz2kcLCknyGW5MGjkljRFVL8xJOKyi4CwCOuQAeAkfTP1+tNxLkogvgEbDgffkJqKqvuMA5ifOpqg/5qWecRstNg7xoUTI1Fovdxg8oy2s5AP8CGeYHmGngeZaOL4I4LXLcpHg4149/GDz4xqgsb+UAbMKKUpkrqHA43MUyyJpWUK0EHeG2YKRXr7tB+QMcgGewLD+ebTDbtrtbBt7UPlhS4rV4IvcDI7J8P1OeA/AcAI7LHljN7aB8XTowJmZt9EFRD/o0SDMH4HlwMhMyDWZZSAHFf3YDs3RS49WDLuaAY3IJq+qzmQKLxXAZKN7oDoYbdV3v5elPqiSpMyiOuAEVZVqHXb1OhloUH+MA+ztO0cAO/RkrfyBE7OAEbAZvO8vzVtTRWFD6DAfY5biBM3PWiaL0a4lvXICwnV8WjmE6ntYmhqX2jjp5LbMZjCw/wbYeN6CizOa2GMVzQOlmHjB4Ceuyk6LJ8huccEmR5Xddg7OOV/NAtchW+E3XbOag60QA4Qwuarca0bRuEJyr+cFQwzcY98huxhAKdQelt4kAQpj4qJ3gvF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V4CRtFSxZQ+D0BwNO2jgdkzoGoah1nj3FVlSR19taTSYxI8QLut23U8dsgzqHulJNCQpcqBnpTALCuQ6NSYLHpmR5i42gZzuIdcrMMvMJbQlxe3jXxyZnLACl7ARm/FjPIDOY8ODtpM71sxwfcZpvBeUzKWmfNINM5AS+wO0Khh7dMqKccu4+qatarZjYAwDlgetzStHtEt+XedsBOQtU9XMrRgjg4KTnc5nr+dmqadit/4C4uLm8DuA9koJTj1TL7fI5nDL+qqoo/FLGAzL7dYT17PzvAcQONYSUQRxW/QMrHZVIyik0ZuQA2mzp+Ji8BW4YM3Mbzm9inaHkJCGfrUZZjujiYailfFwA8DHIy3acwUj4v9vUVa+SmgNsl5fuyDTKovW9/IAmfLV0Pi2UncA515kjYdrwC9i9rpuHiq3JwtAAAAABJRU5ErkJggg=="></a>
|
21 |
<a style="display:inline-block; margin-left: .5em" href='https://github.com/byeongjun-park/HarmonyView'><img src='https://img.shields.io/github/stars/byeongjun-park/HarmonyView?style=social' /></a>
|
22 |
</div>
|
23 |
+
Given a single-view image, HarmonyView is able to generate diverse and multiview-consistent images, resulting in creating plausible 3D contents with NeuS or NeRF </br>
|
24 |
|
25 |
Procedure: </br>
|
26 |
+
**Step 1**. Upload an image. ==> The foreground is masked out by SAM. </br>
|
27 |
+
**Step 2**. Select the input to HarmonyView (Input image or SAM output). ==> Then, we crop it as inputs. </br>
|
28 |
+
**Step 3**. Select "Elevation angle "and click "Run generation". ==> Generate multiview images. The **Elevation angle** is the elevation of the Input image. (This costs about 45s.) </br>
|
29 |
You may adjust the **Crop size** and **Elevation angle** to get a better result! <br>
|
30 |
To reconstruct a NeRF or a 3D mesh from the generated images, please refer to our [github repository](https://github.com/byeongjun-park/HarmonyView). <br>
|
31 |
We have heavily borrowed codes from [Syncdreamer](https://huggingface.co/spaces/liuyuan-pal/SyncDreamer), which is an our strong baseline.
|
32 |
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
deployed = True
|
35 |
|
|
|
175 |
|
176 |
# NOTE: Examples must match inputs
|
177 |
examples_full = [
|
178 |
+
['hf_demo/examples/dragon.png',30,200,"Input image"],
|
179 |
+
['hf_demo/examples/drum_kids.png',15,240,"Input image"],
|
180 |
+
['hf_demo/examples/table.png',30,200,"Input image"],
|
181 |
+
['hf_demo/examples/panda_back.png', 15, 240, "SAM output"],
|
182 |
+
['hf_demo/examples/boxer_toy.png', 30, 220, "SAM output"],
|
183 |
+
['hf_demo/examples/rose.png',30,200,"Input image"],
|
184 |
+
['hf_demo/examples/monkey.png', 30, 200, "SAM output"],
|
185 |
['hf_demo/examples/forest.png',30,200,"SAM output"],
|
186 |
+
['hf_demo/examples/flower.png',0,200,"SAM output"],
|
187 |
['hf_demo/examples/teapot.png',20,200,"SAM output"],
|
|
|
188 |
]
|
189 |
|
190 |
image_block = gr.Image(type='pil', image_mode='RGBA', height=256, label='Input image', tool=None, interactive=True)
|
|
|
213 |
|
214 |
with gr.Column(scale=0.8):
|
215 |
image_block.render()
|
|
|
216 |
crop_size.render()
|
217 |
fig0 = gr.Image(value=Image.open('assets/crop_size.jpg'), type='pil', image_mode='RGB', height=256, show_label=False, tool=None, interactive=False)
|
218 |
|
|
|
234 |
|
235 |
output_block = gr.Image(type='pil', image_mode='RGB', label="Outputs of HarmonyView", height=256, interactive=False)
|
236 |
|
237 |
+
image_block.change(fn=partial(sam_predict, mask_predictor, removal), inputs=[image_block], outputs=[sam_block], queue=True)
|
|
|
|
|
238 |
background_removal.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
|
239 |
crop_size.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
|
240 |
|
hf_demo/examples/{cat.png β boxer_toy.png}
RENAMED
File without changes
|
hf_demo/examples/{crab.png β dragon.png}
RENAMED
File without changes
|
hf_demo/examples/{elephant.png β drum_kids.png}
RENAMED
File without changes
|
hf_demo/examples/{basket.png β panda_back.png}
RENAMED
File without changes
|
hf_demo/examples/rose.png
ADDED
Git LFS Details
|
hf_demo/examples/table.png
ADDED
Git LFS Details
|