Spaces:
Runtime error
Runtime error
Adding examples and updating description
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import logging
|
2 |
-
import os
|
3 |
|
4 |
import gradio as gr
|
5 |
import keras_cv
|
@@ -17,9 +16,8 @@ logger.info(f'Loading text encoder from: "{text_encoder_url}"')
|
|
17 |
|
18 |
stable_diffusion = keras_cv.models.StableDiffusion()
|
19 |
stable_diffusion.tokenizer.add_tokens(prompt_token)
|
20 |
-
|
21 |
-
|
22 |
-
stable_diffusion._text_encoder = loaded_text_encoder_
|
23 |
stable_diffusion._text_encoder.compile(jit_compile=True)
|
24 |
|
25 |
|
@@ -33,7 +31,7 @@ def generate_fn(input_prompt: str) -> np.ndarray:
|
|
33 |
np.ndarray: Generated image
|
34 |
"""
|
35 |
generated = stable_diffusion.text_to_image(
|
36 |
-
prompt=input_prompt, batch_size=1, num_steps=
|
37 |
)
|
38 |
return generated[0]
|
39 |
|
@@ -41,7 +39,7 @@ def generate_fn(input_prompt: str) -> np.ndarray:
|
|
41 |
iface = gr.Interface(
|
42 |
fn=generate_fn,
|
43 |
title="Textual Inversion",
|
44 |
-
description=
|
45 |
article="Note: Keras-cv uses lazy intialization, so the first use will be slower while the model is initialized.",
|
46 |
inputs=gr.Textbox(
|
47 |
label="Prompt",
|
@@ -51,6 +49,10 @@ iface = gr.Interface(
|
|
51 |
elem_id="input-prompt",
|
52 |
),
|
53 |
outputs=gr.Image(),
|
|
|
|
|
|
|
|
|
54 |
)
|
55 |
|
56 |
if __name__ == "__main__":
|
|
|
1 |
import logging
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import keras_cv
|
|
|
16 |
|
17 |
stable_diffusion = keras_cv.models.StableDiffusion()
|
18 |
stable_diffusion.tokenizer.add_tokens(prompt_token)
|
19 |
+
text_encoder = from_pretrained_keras("Dimitre/stablediffusion-canarinho_pistola")
|
20 |
+
stable_diffusion._text_encoder = text_encoder
|
|
|
21 |
stable_diffusion._text_encoder.compile(jit_compile=True)
|
22 |
|
23 |
|
|
|
31 |
np.ndarray: Generated image
|
32 |
"""
|
33 |
generated = stable_diffusion.text_to_image(
|
34 |
+
prompt=input_prompt, batch_size=1, num_steps=50
|
35 |
)
|
36 |
return generated[0]
|
37 |
|
|
|
39 |
iface = gr.Interface(
|
40 |
fn=generate_fn,
|
41 |
title="Textual Inversion",
|
42 |
+
description=f'Textual Inversion Demo, use "{prompt_token}" as the textual inversion token as shown in the examples',
|
43 |
article="Note: Keras-cv uses lazy intialization, so the first use will be slower while the model is initialized.",
|
44 |
inputs=gr.Textbox(
|
45 |
label="Prompt",
|
|
|
49 |
elem_id="input-prompt",
|
50 |
),
|
51 |
outputs=gr.Image(),
|
52 |
+
examples=[
|
53 |
+
["A {prompt_token} drinking beer, 4k, highly detailed, highest quality, 8k"],
|
54 |
+
["A {prompt_token} portrait, 4k, highly detailed, highest quality, 8k"],
|
55 |
+
],
|
56 |
)
|
57 |
|
58 |
if __name__ == "__main__":
|