Spaces:
Sleeping
Sleeping
File size: 984 Bytes
948896c c01fe81 42d6a19 948896c c01fe81 c7a28d2 c01fe81 948896c c01fe81 70eb5ba c01fe81 948896c 0e698b0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
import os
token = os.getenv('token')
from huggingface_hub import login
login(token=token)
gr.load("models/black-forest-labs/FLUX.1-dev").launch()
# Load the model (you can replace this with the specific Kwai-Kolors/Kolors model if available)
pipe = StableDiffusionPipeline.from_pretrained("Kwai-Kolors/Kolors")
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
# Define function to generate image from text
def generate_image(prompt):
# Generate an image based on the provided text prompt
image = pipe(prompt).images[0]
return image
# Create Gradio interface for chatbot
interface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter your prompt:"),
outputs=gr.Image(type="pil"),
live=True,
title="Text-to-Image Generation",
description="Enter a text prompt to generate a photorealistic image."
)
# Launch the interface
interface.launch()
|