Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from diffusers import StableDiffusionImg2ImgPipeline | |
| import torch | |
| from PIL import Image | |
| pipe = StableDiffusionImg2ImgPipeline.from_pretrained( | |
| "hf-internal-testing/tiny-stable-diffusion-pipe", | |
| torch_dtype=torch.float32 | |
| ) | |
| def generate(image, prompt): | |
| if image is None: | |
| return None | |
| img = image.convert("RGB").resize((512, 512)) | |
| full_prompt = f"interior design, {prompt}, photorealistic, high quality" | |
| negative_prompt = "ugly, blurry, bad quality, distorted" | |
| result = pipe( | |
| prompt=full_prompt, | |
| negative_prompt=negative_prompt, | |
| image=img, | |
| strength=0.75, | |
| guidance_scale=7.5, | |
| num_inference_steps=8, | |
| ).images[0] | |
| return result | |
| demo = gr.Interface( | |
| fn=generate, | |
| inputs=[ | |
| gr.Image(type="pil", label="Leeg interieur render"), | |
| gr.Textbox(label="Stijl omschrijving") | |
| ], | |
| outputs=gr.Image(type="pil", label="Resultaat"), | |
| title="Interior AI" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |