ai-dreams-x / gradio_interface.py
AIVISIONDREAMS's picture
Upload folder using huggingface_hub
32d4b56 verified
raw
history blame contribute delete
No virus
577 Bytes
import torch
from diffusers import StableDiffusionPipeline
import gradio as gr
model_id = "CompVis/stable-diffusion-v1-4"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
pipe = pipe.to("cpu") # Use CPU instead of CUDA
def generate_image(prompt):
image = pipe(prompt).images[0]
return image
demo = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Text Prompt"),
outputs="image",
title="AI Image Generator",
description="Generate images from text prompts using Stable Diffusion."
)
if __name__ == "__main__":
demo.launch()