Spaces:
Running
on
Zero
Running
on
Zero
TheAwakenOne
commited on
Commit
•
44f98f9
1
Parent(s):
b64cb38
Updated app with random seed and 25 fixed steps
Browse files
app.py
CHANGED
@@ -3,8 +3,9 @@ import torch
|
|
3 |
from diffusers import FluxPipeline
|
4 |
from huggingface_hub import HfApi
|
5 |
import spaces
|
|
|
6 |
|
7 |
-
@spaces.GPU(duration=70)
|
8 |
def initialize_model():
|
9 |
model_id = "Freepik/flux.1-lite-8B-alpha"
|
10 |
pipe = FluxPipeline.from_pretrained(
|
@@ -17,14 +18,16 @@ def initialize_model():
|
|
17 |
def generate_image(
|
18 |
prompt,
|
19 |
guidance_scale=3.5,
|
20 |
-
num_steps=
|
21 |
-
seed=11,
|
22 |
width=1024,
|
23 |
height=1024
|
24 |
):
|
25 |
# Initialize model within the GPU context
|
26 |
pipe = initialize_model()
|
27 |
|
|
|
|
|
|
|
28 |
with torch.inference_mode():
|
29 |
image = pipe(
|
30 |
prompt=prompt,
|
@@ -43,17 +46,15 @@ demo = gr.Interface(
|
|
43 |
inputs=[
|
44 |
gr.Textbox(label="Prompt", placeholder="Enter your image description here..."),
|
45 |
gr.Slider(minimum=1, maximum=20, value=3.5, label="Guidance Scale", step=0.5),
|
46 |
-
gr.Slider(minimum=1, maximum=50, value=28, label="Number of Steps", step=1),
|
47 |
-
gr.Slider(minimum=1, maximum=1000000, value=11, label="Seed", step=1),
|
48 |
gr.Slider(minimum=128, maximum=1024, value=1024, label="Width", step=64),
|
49 |
gr.Slider(minimum=128, maximum=1024, value=1024, label="Height", step=64)
|
50 |
],
|
51 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
52 |
title="Flux Image Generator (Zero-GPU)",
|
53 |
-
description="Generate images using Freepik's Flux model with Zero-GPU allocation",
|
54 |
examples=[
|
55 |
-
["A close-up image of a green alien with fluorescent skin in the middle of a dark purple forest", 3.5,
|
56 |
-
["A serene landscape with mountains at sunset", 3.5,
|
57 |
]
|
58 |
)
|
59 |
|
|
|
3 |
from diffusers import FluxPipeline
|
4 |
from huggingface_hub import HfApi
|
5 |
import spaces
|
6 |
+
import random
|
7 |
|
8 |
+
@spaces.GPU(duration=70)
|
9 |
def initialize_model():
|
10 |
model_id = "Freepik/flux.1-lite-8B-alpha"
|
11 |
pipe = FluxPipeline.from_pretrained(
|
|
|
18 |
def generate_image(
|
19 |
prompt,
|
20 |
guidance_scale=3.5,
|
21 |
+
num_steps=25, # Changed default to 25
|
|
|
22 |
width=1024,
|
23 |
height=1024
|
24 |
):
|
25 |
# Initialize model within the GPU context
|
26 |
pipe = initialize_model()
|
27 |
|
28 |
+
# Generate random seed
|
29 |
+
seed = random.randint(1, 1000000)
|
30 |
+
|
31 |
with torch.inference_mode():
|
32 |
image = pipe(
|
33 |
prompt=prompt,
|
|
|
46 |
inputs=[
|
47 |
gr.Textbox(label="Prompt", placeholder="Enter your image description here..."),
|
48 |
gr.Slider(minimum=1, maximum=20, value=3.5, label="Guidance Scale", step=0.5),
|
|
|
|
|
49 |
gr.Slider(minimum=128, maximum=1024, value=1024, label="Width", step=64),
|
50 |
gr.Slider(minimum=128, maximum=1024, value=1024, label="Height", step=64)
|
51 |
],
|
52 |
outputs=gr.Image(type="pil", label="Generated Image"),
|
53 |
title="Flux Image Generator (Zero-GPU)",
|
54 |
+
description="Generate images using Freepik's Flux model with Zero-GPU allocation. Using 25 steps and random seed for each generation.",
|
55 |
examples=[
|
56 |
+
["A close-up image of a green alien with fluorescent skin in the middle of a dark purple forest", 3.5, 1024, 1024],
|
57 |
+
["A serene landscape with mountains at sunset", 3.5, 1024, 1024],
|
58 |
]
|
59 |
)
|
60 |
|