Spaces:
Runtime error
Runtime error
Update space
Browse files
app.py
CHANGED
@@ -1,3 +1,35 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import random
|
4 |
|
5 |
+
# Load your model with LoRA weights
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
|
7 |
+
pipe.load_lora_weights("fyp1/pattern_generation")
|
8 |
+
|
9 |
+
def generate_images(prompt, num_images=3):
|
10 |
+
# Generate multiple images based on the prompt
|
11 |
+
images = []
|
12 |
+
|
13 |
+
for _ in range(num_images):
|
14 |
+
# Generate a random seed for each image to ensure diversity
|
15 |
+
seed = random.randint(0, 100000)
|
16 |
+
image = pipe(prompt, parameters={"seed": seed}).images[0]
|
17 |
+
images.append(image)
|
18 |
+
|
19 |
+
return images
|
20 |
+
|
21 |
+
# Define the Gradio interface
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=generate_images,
|
24 |
+
inputs=[
|
25 |
+
gr.Textbox(label="Enter your prompt", lines=2, placeholder="A Kashmiri shawl-inspired pattern..."),
|
26 |
+
gr.Slider(minimum=1, maximum=10, value=3, step=1, label="Number of images to generate")
|
27 |
+
],
|
28 |
+
outputs=[
|
29 |
+
gr.Gallery(label="Generated Images").style(height=300)
|
30 |
+
],
|
31 |
+
title="Pattern Generation",
|
32 |
+
description="Generate multiple unique patterns based on your prompt."
|
33 |
+
)
|
34 |
+
|
35 |
+
iface.launch()
|