|
from huggingface_hub import from_pretrained_keras |
|
from keras_cv import models |
|
import gradio as gr |
|
|
|
sd_dreambooth_model = models.StableDiffusion( |
|
img_width=512, img_height=512 |
|
) |
|
db_diffusion_model = from_pretrained_keras("keras-dreambooth/dreambooth_kedis") |
|
sd_dreambooth_model._diffusion_model = db_diffusion_model |
|
|
|
|
|
def infer(prompt, negative_prompt, num_imgs_to_gen, num_steps, guidance_scale): |
|
generated_images = sd_dreambooth_model.text_to_image( |
|
prompt, |
|
negative_prompt=negative_prompt, |
|
batch_size=num_imgs_to_gen, |
|
num_steps=num_steps, |
|
unconditional_guidance_scale=guidance_scale |
|
) |
|
return generated_images |
|
|
|
|
|
|
|
|
|
|
|
gr.Interface( |
|
infer, [ |
|
gr.Textbox(label="Positive Prompt", value="a kedis cat as a princess with tiara"), |
|
gr.Textbox(label="Negative Prompt", value="bad anatomy, blurry"), |
|
gr.Slider(label='Number of gen image', minimum=1, maximum=4, value=2, step=1), |
|
gr.Slider(label="Inference Steps",value=50), |
|
gr.Number(label='Guidance scale', value=7.5), |
|
], [ |
|
gr.Gallery(show_label=False), |
|
], |
|
title="Dreambooth Kedis", |
|
description = "This dreambooth model is fine-tuned on my cat, Kediş (meaning, kitten in Turkish). She's a tabby cat I adopted on a stormy day in the street. You can prompt using the special indicator {kedis cat}.", |
|
examples = [["photo of kedis cat as astronaut, high quality, blender, 3d, trending on artstation, 8k", "bad, ugly", 1, 50, 7.5], |
|
["kedis cat as a princess with tiara", "bad, ugly", 2, 50, 7.5]], cache_examples=True |
|
).queue().launch() |