Spaces:
Sleeping
Sleeping
Update app.py
Browse files1232356789101145613147891011161718192021222324252627121314151617181920212223243025import gradio as grimport torchfrom diffusers import DiffusionPipelinefrom transformers import pipeline
# Load model oncepipe = DiffusionPipeline.from_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")# Load the model from the hubgenerator = pipeline("text2text-generation", model="DetectiveShadow/inspiration-message-generator")
# Load the LoRA weightspipe.load_lora_weights("ZB-Tech/Text-to-Image")def generate_message(age, profession, archetype): prompt = f"Age: {age} | Profession: {profession} | Archetype: {archetype}" result = generator(prompt, max_new_tokens=100)[0]["generated_text"] return result
# Define generation functiondef generate_image(prompt): image = pipe(prompt).images[0] return image
# Gradio UIdemo = gr.Interface( fn=generate_image, inputs=gr.Textbox(label="Enter a prompt", placeholder="e.g. Draw a picture of some coding on a screen with a horror background"), outputs=gr.Image(type="pil", label="Generated Image"), title="🎨 AI Image Generator", description="This demo uses Stable Diffusion XL with custom LoRA weights to generate images from your prompts."# Gradio interfaceiface = gr.Interface( fn=generate_message, inputs=[ gr.Textbox(label="Age"), gr.Textbox(label="Profession"), gr.Textbox(label="Archetype") ], outputs="text", title="Inspiration Message Generator", description="Enter age, profession, and archetype to get a personalized inspirational message.")
demo.launch()iface.launch()app.py+19-24