new commit
Browse files- README.md +2 -1
- app.py +21 -31
- requirements.txt +2 -1
README.md
CHANGED
@@ -4,7 +4,8 @@ emoji: 🚀
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
python_version: 3.9
|
8 |
+
sdk_version: 4.44.0
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
---
|
app.py
CHANGED
@@ -69,7 +69,7 @@ def image_preprocess(image: Image, mode="RGB", return_orig=False):
|
|
69 |
return out_img
|
70 |
|
71 |
|
72 |
-
def infer(
|
73 |
source = image["background"].convert("RGB").resize(size)
|
74 |
|
75 |
mask = image["layers"][0]
|
@@ -161,13 +161,9 @@ prefix = ""
|
|
161 |
title = f"""
|
162 |
<div class="main-div">
|
163 |
<div>
|
164 |
-
<h1>
|
165 |
</div>
|
166 |
-
<
|
167 |
-
Demo for <a href="https://huggingface.co/OFA-Sys/small-stable-diffusion-v0">Small Stable Diffusion V0</a> Stable Diffusion model.<br>
|
168 |
-
{"Add the following tokens to your prompts for the model to work properly: <b>prefix</b>" if prefix else ""}
|
169 |
-
</p>
|
170 |
-
Running on {"<b>GPU 🔥</b>" if torch.cuda.is_available() else f"<b>CPU 🥶</b>. For faster inference it is recommended to <b>upgrade to GPU in <a href='https://huggingface.co/spaces/akhaliq/small-stable-diffusion-v0/settings'>Settings</a></b>"} after duplicating the space<br><br>
|
171 |
<a style="display:inline-block" href="https://huggingface.co/spaces/akhaliq/small-stable-diffusion-v0?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
172 |
</div>
|
173 |
"""
|
@@ -176,12 +172,6 @@ with gr.Blocks(css=css) as demo:
|
|
176 |
gr.HTML(title)
|
177 |
with gr.Row():
|
178 |
with gr.Row():
|
179 |
-
with gr.Column():
|
180 |
-
prompt = gr.Textbox(
|
181 |
-
label="Prompt",
|
182 |
-
info="Describe what to inpaint the mask with",
|
183 |
-
lines=3,
|
184 |
-
)
|
185 |
with gr.Column():
|
186 |
with gr.Row():
|
187 |
with gr.Column():
|
@@ -219,7 +209,7 @@ with gr.Blocks(css=css) as demo:
|
|
219 |
outputs=use_as_input_button,
|
220 |
).then(
|
221 |
fn=infer,
|
222 |
-
inputs=[
|
223 |
outputs=result,
|
224 |
).then(
|
225 |
fn=lambda: gr.update(visible=True),
|
@@ -227,22 +217,22 @@ with gr.Blocks(css=css) as demo:
|
|
227 |
outputs=use_as_input_button,
|
228 |
)
|
229 |
|
230 |
-
prompt.submit(
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
).then(
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
).then(
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
).then(
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
)
|
247 |
|
248 |
demo.launch()
|
|
|
69 |
return out_img
|
70 |
|
71 |
|
72 |
+
def infer(image):
|
73 |
source = image["background"].convert("RGB").resize(size)
|
74 |
|
75 |
mask = image["layers"][0]
|
|
|
161 |
title = f"""
|
162 |
<div class="main-div">
|
163 |
<div>
|
164 |
+
<h1>Lama model</h1>
|
165 |
</div>
|
166 |
+
Running on {"<b>GPU 🔥</b>" if torch.cuda.is_available() else "<b>CPU 🥶</b>"} <br><br>
|
|
|
|
|
|
|
|
|
167 |
<a style="display:inline-block" href="https://huggingface.co/spaces/akhaliq/small-stable-diffusion-v0?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
|
168 |
</div>
|
169 |
"""
|
|
|
172 |
gr.HTML(title)
|
173 |
with gr.Row():
|
174 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
with gr.Column():
|
176 |
with gr.Row():
|
177 |
with gr.Column():
|
|
|
209 |
outputs=use_as_input_button,
|
210 |
).then(
|
211 |
fn=infer,
|
212 |
+
inputs=[input_image],
|
213 |
outputs=result,
|
214 |
).then(
|
215 |
fn=lambda: gr.update(visible=True),
|
|
|
217 |
outputs=use_as_input_button,
|
218 |
)
|
219 |
|
220 |
+
# prompt.submit(
|
221 |
+
# fn=clear_result,
|
222 |
+
# inputs=None,
|
223 |
+
# outputs=result,
|
224 |
+
# ).then(
|
225 |
+
# fn=lambda: gr.update(visible=False),
|
226 |
+
# inputs=None,
|
227 |
+
# outputs=use_as_input_button,
|
228 |
+
# ).then(
|
229 |
+
# fn=infer,
|
230 |
+
# inputs=[prompt, input_image],
|
231 |
+
# outputs=result,
|
232 |
+
# ).then(
|
233 |
+
# fn=lambda: gr.update(visible=True),
|
234 |
+
# inputs=None,
|
235 |
+
# outputs=use_as_input_button,
|
236 |
+
# )
|
237 |
|
238 |
demo.launch()
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
pyyaml
|
2 |
tqdm
|
3 |
-
|
|
|
4 |
easydict==1.9.0
|
5 |
scikit-image==0.17.2
|
6 |
scikit-learn==0.24.2
|
|
|
1 |
pyyaml
|
2 |
tqdm
|
3 |
+
mxnet-mkl==1.6.0
|
4 |
+
numpy==1.23.1
|
5 |
easydict==1.9.0
|
6 |
scikit-image==0.17.2
|
7 |
scikit-learn==0.24.2
|