Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021222324252627282930import gradio as grimport torchfrom diffusers import DiffusionPipeline# 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 LoRA weightspipe.load_lora_weights("ZB-Tech/Text-to-Image")# 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.")demo.launch()12345678910111213141516171819202122232425import gradio as grfrom transformers import pipeline# Load the model from the hubgenerator = pipeline("text2text-generation", model="DetectiveShadow/inspiration-message-generator")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# 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.")iface.launch()
app.py+19-24