amankishore commited on
Commit
ef2e9bf
1 Parent(s): f7da062

Depth2Img Mirage

Browse files
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.Markdown("## Stable Diffusion 2 Depth2Img")
64
- 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>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- source='upload', type="pil", label="Depth image Optional", value=None)
 
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=50, value=50, step=1)
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/baby.jpg", "high definition photo of a baby astronaut space walking at the international space station with earth seeing from above in the background",
100
- "", 50, 4, 9.0, 123123123, 0.8, None],
101
- ["./examples/gol.jpg", "professional photo of a Elmo jumping between two high rises, beautiful colorful city landscape in the background",
102
- "", 50, 4, 9.0, 1734133747, 0.9, None],
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, depth_image],
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, depth_image], outputs=[gallery])
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

  • SHA256: 9945dff68c9cbe89a06e9443fff242014460f6f003f39f451163d21cf2595d0a
  • Pointer size: 131 Bytes
  • Size of remote file: 920 kB
examples/gol.jpg DELETED
Binary file (231 kB)
 
examples/hogwarts_iso.png ADDED

Git LFS Details

  • SHA256: e070c31da2f69416a6a18479fbd827ff52db90f5b9bfd2fe608af5bf5eeddf96
  • Pointer size: 132 Bytes
  • Size of remote file: 1.73 MB
examples/original_iso.png ADDED

Git LFS Details

  • SHA256: e74201899d9103c5882e126de13659ef7409f0f96827e2c6f456a8a757d974c5
  • Pointer size: 132 Bytes
  • Size of remote file: 2.93 MB
examples/original_sword.png ADDED

Git LFS Details

  • SHA256: d616fc0520b897aa8a415d243848b3966ada2b6b53095a1984b75f3909a5e2fd
  • Pointer size: 131 Bytes
  • Size of remote file: 491 kB
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

  • SHA256: 2f4a8fbf573261446f0c31672272925b7ebb373cc57cf6ca21afc5bb735e331f
  • Pointer size: 130 Bytes
  • Size of remote file: 28.2 kB