Update app.py
Browse files
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.
|
116 |
-
with gr.
|
117 |
-
with gr.
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
with gr.
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
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 |
+
)
|
|
|
|
|
|
|
|