from huggingface_hub import from_pretrained_keras import keras_cv import gradio as gr from tensorflow import keras keras.mixed_precision.set_global_policy("mixed_float16") resolution = 512 dreambooth_model = keras_cv.models.StableDiffusion( img_width=resolution, img_height=resolution, jit_compile=True, ) loaded_diffusion_model = from_pretrained_keras("melanit/dreambooth_voyager_v2") dreambooth_model._diffusion_model = loaded_diffusion_model def generate_images(prompt: str, negative_prompt:str, batch_size: int, num_steps: int): """ This function will infer the trained dreambooth (stable diffusion) model Args: prompt (str): The input text batch_size (int): The number of images to be generated num_steps (int): The number of denoising steps Returns: outputs (List): List of images that were generated using the model """ outputs = dreambooth_model.text_to_image( prompt, negative_prompt=negative_prompt, batch_size=batch_size, num_steps=num_steps, ) return outputs with gr.Blocks() as demo: gr.HTML("