Skip to content

Commit 02b4b52

Browse files
Update app.py
1 parent eb39d4c commit 02b4b52

File tree

1 file changed

+81
-121
lines changed

1 file changed

+81
-121
lines changed

app.py

+81-121
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88
from typing import Tuple
99
import numpy as np
1010

11-
DESCRIPTIONz = """## FLUX REALISM 🦁"""
12-
13-
14-
DESCRIPTIONy = """
15-
<p align="left">
16-
<a title="Github" href="https://github.com/PRITHIVSAKTHIUR/FLUX-REALPIX" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
17-
<img src="https://img.shields.io/github/stars/PRITHIVSAKTHIUR/FLUX-REALPIX?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
18-
</a>
19-
</p>
20-
"""
21-
2211
def save_image(img):
2312
unique_name = str(uuid.uuid4()) + ".png"
2413
img.save(unique_name)
@@ -101,111 +90,103 @@ def generate(
10190
print(image_paths)
10291
return image_paths, seed
10392

104-
105-
def load_predefined_images():
106-
predefined_images = [
107-
"assets/11.png",
108-
"assets/22.png",
109-
"assets/33.png",
110-
"assets/44.png",
111-
"assets/55.webp",
112-
"assets/66.png",
113-
"assets/77.png",
114-
"assets/88.png",
115-
"assets/99.png",
116-
]
117-
return predefined_images
118-
119-
120-
12193
examples = [
122-
"A portrait of an attractive woman in her late twenties with light brown hair and purple, wearing large a a yellow sweater. She is looking directly at the camera, standing outdoors near trees.. --ar 128:85 --v 6.0 --style raw",
123-
"A photo of the model wearing a white bodysuit and beige trench coat, posing in front of a train station with hands on head, soft light, sunset, fashion photography, high resolution, 35mm lens, f/22, natural lighting, global illumination. --ar 85:128 --v 6.0 --style raw",
94+
"Woman in a red jacket, snowy, in the style of hyper-realistic portraiture, caninecore, mountainous vistas, timeless beauty, palewave, iconic, distinctive noses --ar 72:101 --stylize 750 --v 6",
95+
"Super Realism, Headshot of handsome young man, wearing dark gray sweater with buttons and big shawl collar, brown hair and short beard, serious look on his face, black background, soft studio lighting, portrait photography --ar 85:128 --v 6.0 --style",
96+
"Super Realism, High-resolution photograph, woman, UHD, photorealistic, shot on a Sony A7III --chaos 20 --ar 1:2 --style raw --stylize 250",
97+
"Super-realism, Purple Dreamy, a medium-angle shot of a young woman with long brown hair, wearing a pair of eye-level glasses, stands in front of a backdrop of purple and white lights. The womans eyes are closed, her lips are slightly parted, as if she is looking up at the sky. Her hair is cascading over her shoulders, framing her face. She is wearing a sleeveless top, adorned with tiny white dots, and a gold chain necklace around her neck. Her left earrings are dangling from her ears, adding a pop of color to the scene."
12498
]
12599

126-
127100
css = '''
128-
.gradio-container{max-width: 595px !important}
101+
.gradio-container{max-width: 888px !important}
129102
h1{text-align:center}
130103
footer {
131104
visibility: hidden
132105
}
106+
.submit-btn {
107+
background-color: #e34949 !important;
108+
color: white !important;
109+
}
110+
.submit-btn:hover {
111+
background-color: #ff3b3b !important;
112+
}
133113
'''
134114

135115
with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
136-
gr.Markdown(DESCRIPTIONz)
137-
138116
with gr.Row():
139-
prompt = gr.Text(
140-
label="Prompt",
141-
show_label=False,
142-
max_lines=1,
143-
placeholder="Enter your prompt",
144-
container=False,
145-
)
146-
run_button = gr.Button("Run", scale=0)
147-
result = gr.Gallery(label="Result", columns=1, show_label=False)
148-
149-
with gr.Accordion("Advanced options", open=False, visible=True):
150-
seed = gr.Slider(
151-
label="Seed",
152-
minimum=0,
153-
maximum=MAX_SEED,
154-
step=1,
155-
value=0,
156-
visible=True
157-
)
158-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
159-
160-
with gr.Row(visible=True):
161-
width = gr.Slider(
162-
label="Width",
163-
minimum=512,
164-
maximum=2048,
165-
step=64,
166-
value=1024,
167-
)
168-
height = gr.Slider(
169-
label="Height",
170-
minimum=512,
171-
maximum=2048,
172-
step=64,
173-
value=1024,
117+
with gr.Column(scale=1):
118+
prompt = gr.Text(
119+
label="Prompt",
120+
show_label=False,
121+
max_lines=1,
122+
placeholder="Enter your prompt",
123+
container=False,
174124
)
125+
run_button = gr.Button("Generate as ( 768 x 1024 )🤗", scale=0, elem_classes="submit-btn")
126+
127+
with gr.Accordion("Advanced options", open=True, visible=True):
128+
seed = gr.Slider(
129+
label="Seed",
130+
minimum=0,
131+
maximum=MAX_SEED,
132+
step=1,
133+
value=0,
134+
visible=True
135+
)
136+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
137+
138+
with gr.Row(visible=True):
139+
width = gr.Slider(
140+
label="Width",
141+
minimum=512,
142+
maximum=2048,
143+
step=64,
144+
value=768,
145+
)
146+
height = gr.Slider(
147+
label="Height",
148+
minimum=512,
149+
maximum=2048,
150+
step=64,
151+
value=1024,
152+
)
153+
154+
with gr.Row():
155+
guidance_scale = gr.Slider(
156+
label="Guidance Scale",
157+
minimum=0.1,
158+
maximum=20.0,
159+
step=0.1,
160+
value=3.0,
161+
)
162+
num_inference_steps = gr.Slider(
163+
label="Number of inference steps",
164+
minimum=1,
165+
maximum=40,
166+
step=1,
167+
value=28,
168+
)
169+
170+
style_selection = gr.Radio(
171+
show_label=True,
172+
container=True,
173+
interactive=True,
174+
choices=STYLE_NAMES,
175+
value=DEFAULT_STYLE_NAME,
176+
label="Quality Style",
177+
)
175178

176-
with gr.Row():
177-
guidance_scale = gr.Slider(
178-
label="Guidance Scale",
179-
minimum=0.1,
180-
maximum=20.0,
181-
step=0.1,
182-
value=3.0,
183-
)
184-
num_inference_steps = gr.Slider(
185-
label="Number of inference steps",
186-
minimum=1,
187-
maximum=40,
188-
step=1,
189-
value=28,
179+
with gr.Column(scale=2):
180+
result = gr.Gallery(label="Result", columns=1, show_label=False)
181+
182+
gr.Examples(
183+
examples=examples,
184+
inputs=prompt,
185+
outputs=[result, seed],
186+
fn=generate,
187+
cache_examples=False,
190188
)
191189

192-
style_selection = gr.Radio(
193-
show_label=True,
194-
container=True,
195-
interactive=True,
196-
choices=STYLE_NAMES,
197-
value=DEFAULT_STYLE_NAME,
198-
label="Quality Style",
199-
)
200-
201-
gr.Examples(
202-
examples=examples,
203-
inputs=prompt,
204-
outputs=[result, seed],
205-
fn=generate,
206-
cache_examples=False,
207-
)
208-
209190
gr.on(
210191
triggers=[
211192
prompt.submit,
@@ -224,27 +205,6 @@ def load_predefined_images():
224205
outputs=[result, seed],
225206
api_name="run",
226207
)
227-
228-
gr.Markdown("### Generated Images")
229-
predefined_gallery = gr.Gallery(label="Generated Images", columns=3, show_label=False, value=load_predefined_images())
230-
231-
gr.Markdown("**Disclaimer/Note:**")
232-
233-
gr.Markdown(DESCRIPTIONy)
234-
235-
#gr.Markdown("🔥This space provides realistic image generation, which works better for human faces and portraits. Realistic trigger works properly, better for photorealistic trigger words, close-up shots, face diffusion, male, female characters.")
236-
237-
#gr.Markdown("🔥users are accountable for the content they generate and are responsible for ensuring it meets appropriate ethical standards.")
238-
239-
gr.Markdown("""
240-
<div style='text-align: justify;'>
241-
🔥This space provides realistic image generation, which works better for human faces and portraits. Realistic trigger works properly, better for photorealistic trigger words, close-up shots, face diffusion, male, female characters.
242-
</div>""")
243-
244-
gr.Markdown("""
245-
<div style='text-align: justify;'>
246-
🔥Users are accountable for the content they generate and are responsible for ensuring it meets appropriate ethical standards.
247-
</div>""")
248208

249209
if __name__ == "__main__":
250210
demo.queue(max_size=40).launch()

0 commit comments

Comments
 (0)