Spaces:
Runtime error
Runtime error
File size: 1,114 Bytes
1109185 120d6fa 1109185 120d6fa |
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 31 32 33 34 35 36 |
import gradio as gr
from diffusers import DiffusionPipeline
import random
# Load your model with LoRA weights
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
pipe.load_lora_weights("fyp1/pattern_generation")
def generate_images(prompt, num_images=3):
# Generate multiple images based on the prompt
images = []
for _ in range(num_images):
# Generate a random seed for each image to ensure diversity
seed = random.randint(0, 100000)
image = pipe(prompt, parameters={"seed": seed}).images[0]
images.append(image)
return images
# Define the Gradio interface
iface = gr.Interface(
fn=generate_images,
inputs=[
gr.Textbox(label="Enter your prompt", lines=2, placeholder="A Kashmiri shawl-inspired pattern..."),
gr.Slider(minimum=1, maximum=10, value=3, step=1, label="Number of images to generate")
],
outputs=[
gr.Gallery(label="Generated Images").style(height=300)
],
title="Pattern Generation",
description="Generate multiple unique patterns based on your prompt."
)
iface.launch()
|