CoolFace
Apppublic

Kvikontent/Kandinsky-V3

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
1likes
app.py26 linesDownload Raw Back to root
1import gradio as gr2import torch3from diffusers import AutoPipelineForText2Image4 5# Load the model6pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-1")7pipe.enable_model_cpu_offload()8 9# Define the input and output functions10def text_to_image(prompt):11    generator = torch.Generator(device="cpu").manual_seed(0)12    image = pipe(prompt, num_inference_steps=25, generator=generator).images[0]13    return image14 15# Create a placeholder16placeholder = "A photograph of the inside of a subway train. There are raccoons sitting on the seats. One of them is reading a newspaper. The window shows the city in the background."17 18# Create the Gradio interface19title = "Kandinsky 3.0"20description = "This model generates an image based on a given text prompt."21how_to_use = "Input a description of the image you want to generate, for example: 'A forest with a river and a bridge under the moonlight.'"22examples = [["A dark alley with flickering streetlights and a mysterious figure lurking in the shadows"], 23            ["A futuristic cityscape with neon lights and flying cars"]]24 25gr.Interface(fn=text_to_image, inputs=gr.Textbox(placeholder=placeholder), outputs=gr.Image()).launch()26