Spaces:
Runtime error
Runtime error
Commit
·
ef2e9bf
1
Parent(s):
f7da062
Depth2Img Mirage
Browse files- app.py +33 -13
- examples/baby.jpg +0 -0
- examples/bag.jpg +0 -0
- examples/depth.jpg +0 -0
- examples/flaming_sword.png +3 -0
- examples/gol.jpg +0 -0
- examples/hogwarts_iso.png +3 -0
- examples/original_iso.png +3 -0
- examples/original_sword.png +3 -0
- examples/smile_depth.jpg +0 -0
- examples/smile_face.jpg +0 -0
- mirage.png +3 -0
app.py
CHANGED
|
@@ -11,6 +11,13 @@ dept2img = StableDiffusionDepth2ImgPipeline.from_pretrained(
|
|
| 11 |
torch_dtype=torch.float16,
|
| 12 |
).to(device)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def pad_image(input_image):
|
| 16 |
pad_w, pad_h = np.max(((2, 2), np.ceil(
|
|
@@ -60,15 +67,30 @@ block = gr.Blocks().queue()
|
|
| 60 |
with block:
|
| 61 |
with gr.Row():
|
| 62 |
with gr.Column():
|
| 63 |
-
gr.
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
with gr.Row():
|
| 68 |
with gr.Column():
|
| 69 |
input_image = gr.Image(source='upload', type="pil")
|
| 70 |
-
depth_image = gr.Image(
|
| 71 |
-
|
|
|
|
| 72 |
prompt = gr.Textbox(label="Prompt")
|
| 73 |
negative_prompt = gr.Textbox(label="Negative Pompt")
|
| 74 |
|
|
@@ -77,7 +99,7 @@ with block:
|
|
| 77 |
num_samples = gr.Slider(
|
| 78 |
label="Images", minimum=1, maximum=4, value=1, step=1)
|
| 79 |
steps = gr.Slider(label="Steps", minimum=1,
|
| 80 |
-
maximum=
|
| 81 |
scale = gr.Slider(
|
| 82 |
label="Guidance Scale", minimum=0.1, maximum=30.0, value=9.0, step=0.1
|
| 83 |
)
|
|
@@ -96,22 +118,20 @@ with block:
|
|
| 96 |
grid=[2], height="auto")
|
| 97 |
gr.Examples(
|
| 98 |
examples=[
|
| 99 |
-
["./examples/
|
| 100 |
-
"", 50, 4,
|
| 101 |
-
["./examples/
|
| 102 |
-
"", 50, 4, 9.0, 1734133747, 0.
|
| 103 |
-
["./examples/bag.jpg", "a photo of a bag of cookies in the bathroom", "low light, dark, blurry", 50, 4, 9.0, 1734133747, 0.9, "./examples/depth.jpg"],
|
| 104 |
-
["./examples/smile_face.jpg", "a hand holding a very spherical orange", "low light, dark, blurry", 50, 4, 6.0, 961736534, 0.5, "./examples/smile_depth.jpg"]
|
| 105 |
|
| 106 |
],
|
| 107 |
inputs=[input_image, prompt, negative_prompt, steps,
|
| 108 |
-
num_samples, scale, seed, strength
|
| 109 |
outputs=[gallery],
|
| 110 |
fn=predict,
|
| 111 |
cache_examples=True,
|
| 112 |
)
|
| 113 |
run_button.click(fn=predict, inputs=[input_image, prompt, negative_prompt,
|
| 114 |
-
steps, num_samples, scale, seed, strength
|
| 115 |
|
| 116 |
|
| 117 |
block.launch(show_api=False)
|
|
|
|
| 11 |
torch_dtype=torch.float16,
|
| 12 |
).to(device)
|
| 13 |
|
| 14 |
+
css = '''
|
| 15 |
+
.instruction{position: absolute; top: 0;right: 0;margin-top: 0px !important}
|
| 16 |
+
.arrow{position: absolute;top: 0;right: -110px;margin-top: -8px !important}
|
| 17 |
+
#component-4, #component-3, #component-10{min-height: 0}
|
| 18 |
+
.duplicate-button img{margin: 0}
|
| 19 |
+
'''
|
| 20 |
+
|
| 21 |
|
| 22 |
def pad_image(input_image):
|
| 23 |
pad_w, pad_h = np.max(((2, 2), np.ceil(
|
|
|
|
| 67 |
with block:
|
| 68 |
with gr.Row():
|
| 69 |
with gr.Column():
|
| 70 |
+
top_description = gr.HTML(f'''
|
| 71 |
+
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
| 72 |
+
<div>
|
| 73 |
+
<img class="logo" src="file/mirage.png" alt="Mirage Logo"
|
| 74 |
+
style="margin: auto; max-width: 7rem;">
|
| 75 |
+
<br />
|
| 76 |
+
<h1 style="font-weight: 900; font-size: 2.5rem;">
|
| 77 |
+
Depth2Img Web UI
|
| 78 |
+
</h1>
|
| 79 |
+
<br />
|
| 80 |
+
<a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/MirageML/dreambooth?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
''')
|
| 84 |
+
# gr.Markdown("## Stable Diffusion 2 Depth2Img")
|
| 85 |
+
# gr.HTML("<p><a href='https://huggingface.co/spaces/radames/stable-diffusion-depth2img?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>")
|
| 86 |
|
| 87 |
|
| 88 |
with gr.Row():
|
| 89 |
with gr.Column():
|
| 90 |
input_image = gr.Image(source='upload', type="pil")
|
| 91 |
+
# depth_image = gr.Image(
|
| 92 |
+
# source='upload', type="pil", label="Depth image Optional", value=None)
|
| 93 |
+
depth_image = None
|
| 94 |
prompt = gr.Textbox(label="Prompt")
|
| 95 |
negative_prompt = gr.Textbox(label="Negative Pompt")
|
| 96 |
|
|
|
|
| 99 |
num_samples = gr.Slider(
|
| 100 |
label="Images", minimum=1, maximum=4, value=1, step=1)
|
| 101 |
steps = gr.Slider(label="Steps", minimum=1,
|
| 102 |
+
maximum=100, value=50, step=1)
|
| 103 |
scale = gr.Slider(
|
| 104 |
label="Guidance Scale", minimum=0.1, maximum=30.0, value=9.0, step=0.1
|
| 105 |
)
|
|
|
|
| 118 |
grid=[2], height="auto")
|
| 119 |
gr.Examples(
|
| 120 |
examples=[
|
| 121 |
+
["./examples/original_iso.png", "hogwarts castle",
|
| 122 |
+
"", 50, 4, 10.0, 123123123, 0.8],
|
| 123 |
+
["./examples/original_sword.png", "flaming sword",
|
| 124 |
+
"", 50, 4, 9.0, 1734133747, 0.8],
|
|
|
|
|
|
|
| 125 |
|
| 126 |
],
|
| 127 |
inputs=[input_image, prompt, negative_prompt, steps,
|
| 128 |
+
num_samples, scale, seed, strength],
|
| 129 |
outputs=[gallery],
|
| 130 |
fn=predict,
|
| 131 |
cache_examples=True,
|
| 132 |
)
|
| 133 |
run_button.click(fn=predict, inputs=[input_image, prompt, negative_prompt,
|
| 134 |
+
steps, num_samples, scale, seed, strength], outputs=[gallery])
|
| 135 |
|
| 136 |
|
| 137 |
block.launch(show_api=False)
|
examples/baby.jpg
DELETED
|
Binary file (53.5 kB)
|
|
|
examples/bag.jpg
DELETED
|
Binary file (369 kB)
|
|
|
examples/depth.jpg
DELETED
|
Binary file (28.8 kB)
|
|
|
examples/flaming_sword.png
ADDED
|
Git LFS Details
|
examples/gol.jpg
DELETED
|
Binary file (231 kB)
|
|
|
examples/hogwarts_iso.png
ADDED
|
Git LFS Details
|
examples/original_iso.png
ADDED
|
Git LFS Details
|
examples/original_sword.png
ADDED
|
Git LFS Details
|
examples/smile_depth.jpg
DELETED
|
Binary file (23.9 kB)
|
|
|
examples/smile_face.jpg
DELETED
|
Binary file (195 kB)
|
|
|
mirage.png
ADDED
|
Git LFS Details
|