Spaces:
Runtime error
Runtime error
ashishtanwer
commited on
Commit
•
968506e
1
Parent(s):
08a7b0a
Update app.py
Browse files
app.py
CHANGED
@@ -4,25 +4,16 @@ import gradio as gr
|
|
4 |
from tensorflow import keras
|
5 |
|
6 |
keras.mixed_precision.set_global_policy("mixed_float16")
|
7 |
-
|
8 |
resolution = 512
|
9 |
dreambooth_model = keras_cv.models.StableDiffusion(
|
10 |
img_width=resolution, img_height=resolution, jit_compile=True,
|
11 |
)
|
12 |
-
loaded_diffusion_model = from_pretrained_keras("
|
13 |
dreambooth_model._diffusion_model = loaded_diffusion_model
|
14 |
|
15 |
|
16 |
def generate_images(prompt: str, negative_prompt:str, num_imgs_to_gen: int, num_steps: int):
|
17 |
-
"""
|
18 |
-
This function is used to generate images using our fine-tuned keras dreambooth stable diffusion model.
|
19 |
-
Args:
|
20 |
-
prompt (str): The text input given by the user based on which images will be generated.
|
21 |
-
num_imgs_to_gen (int): The number of images to be generated using given prompt.
|
22 |
-
num_steps (int): The number of denoising steps
|
23 |
-
Returns:
|
24 |
-
generated_img (List): List of images that were generated using the model
|
25 |
-
"""
|
26 |
generated_img = dreambooth_model.text_to_image(
|
27 |
prompt,
|
28 |
negative_prompt=negative_prompt,
|
@@ -33,10 +24,10 @@ def generate_images(prompt: str, negative_prompt:str, num_imgs_to_gen: int, num_
|
|
33 |
return generated_img
|
34 |
|
35 |
with gr.Blocks() as demo:
|
36 |
-
gr.HTML("<h2 style=\"font-size: 2em; font-weight: bold\" align=\"center\">
|
37 |
with gr.Row():
|
38 |
with gr.Column():
|
39 |
-
prompt = gr.Textbox(lines=1, value="
|
40 |
negative_prompt = gr.Textbox(lines=1, value="deformed", label="Negative Prompt")
|
41 |
samples = gr.Slider(minimum=1, maximum=10, default=1, step=1, label="Number of Image")
|
42 |
num_steps = gr.Slider(label="Inference Steps",value=50)
|
@@ -46,8 +37,7 @@ with gr.Blocks() as demo:
|
|
46 |
|
47 |
run.click(generate_images, inputs=[prompt,negative_prompt, samples, num_steps], outputs=gallery)
|
48 |
|
49 |
-
gr.Examples([["photo of
|
50 |
[prompt,negative_prompt, samples,num_steps], gallery, generate_images)
|
51 |
-
gr.Markdown('\n Demo created by: <a href=\"https://huggingface.co/kadirnar/\">Kadir Nar</a>')
|
52 |
|
53 |
demo.launch(debug=True)
|
|
|
4 |
from tensorflow import keras
|
5 |
|
6 |
keras.mixed_precision.set_global_policy("mixed_float16")
|
7 |
+
|
8 |
resolution = 512
|
9 |
dreambooth_model = keras_cv.models.StableDiffusion(
|
10 |
img_width=resolution, img_height=resolution, jit_compile=True,
|
11 |
)
|
12 |
+
loaded_diffusion_model = from_pretrained_keras("ashishtanwer/shoe")
|
13 |
dreambooth_model._diffusion_model = loaded_diffusion_model
|
14 |
|
15 |
|
16 |
def generate_images(prompt: str, negative_prompt:str, num_imgs_to_gen: int, num_steps: int):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
generated_img = dreambooth_model.text_to_image(
|
18 |
prompt,
|
19 |
negative_prompt=negative_prompt,
|
|
|
24 |
return generated_img
|
25 |
|
26 |
with gr.Blocks() as demo:
|
27 |
+
gr.HTML("<h2 style=\"font-size: 2em; font-weight: bold\" align=\"center\">Radiance Shoe Demo</h2>")
|
28 |
with gr.Row():
|
29 |
with gr.Column():
|
30 |
+
prompt = gr.Textbox(lines=1, value="sshh shoe", label="Base Prompt")
|
31 |
negative_prompt = gr.Textbox(lines=1, value="deformed", label="Negative Prompt")
|
32 |
samples = gr.Slider(minimum=1, maximum=10, default=1, step=1, label="Number of Image")
|
33 |
num_steps = gr.Slider(label="Inference Steps",value=50)
|
|
|
37 |
|
38 |
run.click(generate_images, inputs=[prompt,negative_prompt, samples, num_steps], outputs=gallery)
|
39 |
|
40 |
+
gr.Examples([["photo of sshh shoe","deformed", 1, 50]],
|
41 |
[prompt,negative_prompt, samples,num_steps], gallery, generate_images)
|
|
|
42 |
|
43 |
demo.launch(debug=True)
|