gk8686 commited on
Commit
7280565
β€’
1 Parent(s): b1350fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -49
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
 
3
  from io import BytesIO
@@ -112,52 +114,48 @@ image_list.sort()
112
  image_blocks = gr.Blocks(css=css)
113
  with image_blocks as demo:
114
  gr.HTML(read_content("header.html"))
115
- with gr.Group():
116
- with gr.Box():
117
- with gr.Row():
118
- with gr.Column():
119
- image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Source Image")
120
- reference = gr.Image(source='upload', elem_id="image_upload", type="pil", label="Reference Image")
121
-
122
- with gr.Column():
123
- image_out = gr.Image(label="Output", elem_id="output-img").style(height=400)
124
- guidance = gr.Slider(label="Guidance scale", value=5, maximum=15, interactive=True)
125
- steps = gr.Slider(label="Steps", value=50, minimum=2, maximum=75, step=1, interactive=True)
126
-
127
- seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)
128
-
129
- with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
130
- btn = gr.Button("Paint!").style(
131
- margin=False,
132
- rounded=(False, True, True, False),
133
- full_width=True,
134
- )
135
- with gr.Group(elem_id="share-btn-container"):
136
- community_icon = gr.HTML(community_icon_html, visible=True)
137
- loading_icon = gr.HTML(loading_icon_html, visible=True)
138
- share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
139
-
140
-
141
- with gr.Row():
142
- with gr.Column():
143
- gr.Examples(image_list, inputs=[image],label="Examples - Source Image",examples_per_page=12)
144
- with gr.Column():
145
- gr.Examples(ref_list, inputs=[reference],label="Examples - Reference Image",examples_per_page=12)
146
-
147
- btn.click(fn=predict, inputs=[image, reference, guidance, seed, steps], outputs=[image_out, community_icon, loading_icon, share_button])
148
- share_button.click(None, [], [], _js=share_js)
149
-
150
- gr.HTML(
151
- """
152
- <div class="footer">
153
- <p>Model by <a href="" style="text-decoration: underline;" target="_blank">Fantasy-Studio</a> - Gradio Demo by πŸ€— Hugging Face
154
- </p>
155
- </div>
156
- <div class="acknowledgments">
157
- <p><h4>LICENSE</h4>
158
- The model is licensed with a <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" style="text-decoration: underline;" target="_blank">CreativeML Open RAIL-M</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
159
- """
160
- )
161
-
162
- # Launch the Gradio interface
163
- image_blocks.launch()
 
1
+ pip install accelerate
2
+
3
  import gradio as gr
4
 
5
  from io import BytesIO
 
114
  image_blocks = gr.Blocks(css=css)
115
  with image_blocks as demo:
116
  gr.HTML(read_content("header.html"))
117
+ with gr.Column():
118
+ with gr.Row():
119
+ with gr.Column():
120
+ image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Source Image")
121
+ reference = gr.Image(source='upload', elem_id="image_upload", type="pil", label="Reference Image")
122
+
123
+ with gr.Column():
124
+ image_out = gr.Image(label="Output", elem_id="output-img").style(height=400)
125
+ guidance = gr.Slider(label="Guidance scale", value=5, maximum=15, interactive=True)
126
+ steps = gr.Slider(label="Steps", value=50, minimum=2, maximum=75, step=1, interactive=True)
127
+
128
+ seed = gr.Slider(0, 10000, label='Seed (0 = random)', value=0, step=1)
129
+
130
+ with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
131
+ btn = gr.Button("Paint!").style(
132
+ margin=False,
133
+ rounded=(False, True, True, False),
134
+ full_width=True,
135
+ )
136
+ with gr.Group(elem_id="share-btn-container"):
137
+ community_icon = gr.HTML(community_icon_html, visible=True)
138
+ loading_icon = gr.HTML(loading_icon_html, visible=True)
139
+ share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
140
+
141
+
142
+ with gr.Row():
143
+ with gr.Column():
144
+ gr.Examples(image_list, inputs=[image],label="Examples - Source Image",examples_per_page=12)
145
+ with gr.Column():
146
+ gr.Examples(ref_list, inputs=[reference],label="Examples - Reference Image",examples_per_page=12)
147
+
148
+ btn.click(fn=predict, inputs=[image, reference, guidance, seed, steps], outputs=[image_out, community_icon, loading_icon, share_button])
149
+ share_button.click(None, [], [], _js=share_js)
150
+
151
+ gr.HTML(
152
+ """
153
+ <div class="footer">
154
+ <p>Model by <a href="" style="text-decoration: underline;" target="_blank">Fantasy-Studio</a> - Gradio Demo by πŸ€— Hugging Face
155
+ </p>
156
+ </div>
157
+ <div class="acknowledgments">
158
+ <p><h4>LICENSE</h4>
159
+ The model is licensed with a <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" style="text-decoration: underline;" target="_blank">CreativeML Open RAIL-M</a> license. The authors claim no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in this license. The license forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, spread misinformation and target vulnerable groups. For the full list of restrictions please <a href="https://huggingface.co/spaces/CompVis/stable-diffusion-license" target="_blank" style="text-decoration: underline;" target="_blank">read the license</a></p>
160
+ """
161
+ )