import os import gradio as gr import PIL.Image import numpy as np import random import torch import subprocess from diffusers import StableDiffusionPipeline model_id = "dicoo_model" pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float) def predict(prompt, steps=50, seed=42, guidance_scale=7.5): print("prompt: ", prompt) print("steps: ", steps) image = pipe(prompt, num_inference_steps=steps, guidance_scale=7.5).images[0] return image random_seed = random.randint(0, 2147483647) gr.Interface( predict, inputs=[ gr.inputs.Textbox(label='Prompt', default='a lovely in red dress and hat, in the snowy and brightly night, with many brightly buildings'), gr.inputs.Slider(1, 100, label='Inference Steps', default=50, step=1), gr.inputs.Slider(0, 2147483647, label='Seed', default=random_seed, step=1), gr.inputs.Slider(1.0, 20.0, label='Guidance Scale - how much the prompt will influence the results', default=6.0, step=0.1), ], outputs=gr.Image(shape=[512, 512], type="pil", elem_id="output_image"), css="#output_image{width: 256px}", title="Demo of dicoo-finetuned-diffusion-model using Intel Neural Compressor 🧨", description="This Spaces app is same as Intel/dicoo_diffusion, created by Intel AIA/AIPC team with the model fine-tuned with one shot (one image) for a newly introduced object \"dicoo\". To replicate the model fine-tuning, please refer to the code sample in Intel Neural Compressor. You may also refer to our blog for more details.", ).launch()