File size: 844 Bytes
b32b9e5
2ee0042
b32b9e5
 
2ee0042
 
 
 
 
b32b9e5
2ee0042
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch

# 🔹 Load PosterCraft model from Hugging Face Hub
pipe = StableDiffusionPipeline.from_pretrained(
    "PosterCraft/PosterCraft-v1_RL",   # <-- PosterCraft model
    torch_dtype=torch.float16
)

# Use GPU if available for faster generation
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe.to(device)

def generate_poster(prompt):
    # Generate the poster image
    image = pipe(prompt).images[0]
    return image

# Gradio UI
demo = gr.Interface(
    fn=generate_poster,
    inputs=gr.Textbox(label="Enter your poster prompt"),
    outputs=gr.Image(type="pil", label="Generated Poster"),
    title="AI Poster Generator",
    description="Type something like: 'modern event flyer with bold typography and sunset gradient background'"
)

demo.launch()