Spaces:
Runtime error
Runtime error
| 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() | |