Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -19,11 +19,13 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
19 |
|
20 |
# Illumination options mapping
|
21 |
ILLUMINATION_OPTIONS = {
|
|
|
22 |
"sunshine from window": "Add directional sunlight from window source. Increase brightness on lit areas. Create hard shadows with sharp edges. Set warm white color temperature. Add visible light rays and dust particles in beams.",
|
23 |
"neon night, city": "Replace ambient lighting with neon sources. Set primary colors to electric blue, magenta, and green. Increase color saturation significantly. Add colored reflections on wet surfaces. Reduce overall brightness.",
|
24 |
"sunset over sea": "Set warm orange-red color temperature. Increase warm tones substantially. Add horizontal light source from background. Create soft gradient lighting. Add water reflections if visible.",
|
25 |
"golden time": "Set golden color temperature. Increase contrast moderately. Add rim lighting on subjects. Enhance warm colors. Create soft directional shadows. Reduce blue tones.",
|
26 |
-
"sci-fi RGB glowing, cyberpunk": "
|
|
|
27 |
"natural lighting": "Set neutral white color temperature. Maintain balanced exposure. Create soft shadows with gradual falloff. Preserve original color saturation. Add subtle ambient occlusion.",
|
28 |
"warm atmosphere, at home, bedroom": "Set very warm color temperature. Reduce brightness moderately. Add soft diffused lighting. Increase red and yellow tones. Create minimal shadows.",
|
29 |
"magic lit": "Add subtle colored rim lighting in purple and blue tones. Increase brightness selectively on edges. Add soft glow effects. Create ethereal light sources with no clear origin.",
|
@@ -77,6 +79,7 @@ ILLUMINATION_OPTIONS = {
|
|
77 |
"soft, diffused foggy glow": "Add volumetric fog throughout scene. Reduce contrast substantially. Create soft lighting with no harsh shadows. Set neutral color temperature.",
|
78 |
"underwater luminescence": "Set blue-green color temperature. Add bioluminescent glowing effects. Create caustic light patterns. Add particle effects in water.",
|
79 |
"rain-soaked reflections in city lights": "Add reflections on wet surfaces. Create light streaking effects. Set urban lighting with multiple colored sources. Add rain particle effects.",
|
|
|
80 |
"golden sunlight streaming through trees": "Add god rays effect. Set golden color temperature. Create dappled light patterns. Add atmospheric particles in light beams.",
|
81 |
"fireflies lighting up a summer night": "Add small glowing points of light. Set warm color temperature. Create subtle animated glow effects. Maintain dark ambient lighting.",
|
82 |
"glowing embers from a forge": "Add orange-red glowing particle effects. Set very warm color temperature. Create intense heat glow. Add sparking effects.",
|
@@ -89,7 +92,7 @@ ILLUMINATION_OPTIONS = {
|
|
89 |
}
|
90 |
|
91 |
@spaces.GPU
|
92 |
-
def infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.5, progress=gr.Progress(track_tqdm=True)):
|
93 |
|
94 |
if randomize_seed:
|
95 |
seed = random.randint(0, MAX_SEED)
|
@@ -128,13 +131,20 @@ with gr.Blocks(css=css) as demo:
|
|
128 |
with gr.Column(elem_id="col-container"):
|
129 |
gr.Markdown(f"""# FLUX.1 Kontext [dev] Relight 💡
|
130 |
""")
|
131 |
-
gr.Markdown(f"""Kontext[dev]
|
132 |
""")
|
133 |
|
134 |
with gr.Row():
|
135 |
with gr.Column():
|
136 |
input_image = gr.Image(label="Upload the image for relighting", type="pil")
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
# Illumination options dropdown
|
139 |
illumination_dropdown = gr.Dropdown(
|
140 |
choices=list(ILLUMINATION_OPTIONS.keys()) + ["Custom"],
|
@@ -143,15 +153,7 @@ with gr.Blocks(css=css) as demo:
|
|
143 |
info="Select a predefined lighting style or choose 'Custom' to use your own prompt"
|
144 |
)
|
145 |
|
146 |
-
|
147 |
-
prompt = gr.Textbox(
|
148 |
-
label="Lighting Description",
|
149 |
-
show_label=True,
|
150 |
-
max_lines=3,
|
151 |
-
placeholder="Select an illumination style above or enter your custom description...",
|
152 |
-
value="bright natural sunlight streaming through a window, creating warm golden beams and soft shadows across the scene, with high contrast between lit and shadowed areas",
|
153 |
-
container=True
|
154 |
-
)
|
155 |
|
156 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
157 |
|
@@ -201,7 +203,7 @@ with gr.Blocks(css=css) as demo:
|
|
201 |
gr.on(
|
202 |
triggers=[run_button.click, prompt.submit],
|
203 |
fn = infer,
|
204 |
-
inputs = [input_image, prompt, seed, randomize_seed, guidance_scale],
|
205 |
outputs = [result, seed]
|
206 |
)
|
207 |
|
|
|
19 |
|
20 |
# Illumination options mapping
|
21 |
ILLUMINATION_OPTIONS = {
|
22 |
+
"sunset over sea": "add warm sunset light reflecting off water, creating a peaceful atmosphere with soft, diffused lighting and gentle color gradients",
|
23 |
"sunshine from window": "Add directional sunlight from window source. Increase brightness on lit areas. Create hard shadows with sharp edges. Set warm white color temperature. Add visible light rays and dust particles in beams.",
|
24 |
"neon night, city": "Replace ambient lighting with neon sources. Set primary colors to electric blue, magenta, and green. Increase color saturation significantly. Add colored reflections on wet surfaces. Reduce overall brightness.",
|
25 |
"sunset over sea": "Set warm orange-red color temperature. Increase warm tones substantially. Add horizontal light source from background. Create soft gradient lighting. Add water reflections if visible.",
|
26 |
"golden time": "Set golden color temperature. Increase contrast moderately. Add rim lighting on subjects. Enhance warm colors. Create soft directional shadows. Reduce blue tones.",
|
27 |
+
"sci-fi RGB glowing, cyberpunk": "add futuristic RGB lighting with electric blues, hot pinks, and neon greens creating a high-tech atmosphere with dramatic color separation and glowing effects",
|
28 |
+
"neon night, city":"add vibrant neon lights in electric blues, magentas, and greens casting colorful reflections on surfaces, creating a cyberpunk urban atmosphere with dramatic color contrasts",
|
29 |
"natural lighting": "Set neutral white color temperature. Maintain balanced exposure. Create soft shadows with gradual falloff. Preserve original color saturation. Add subtle ambient occlusion.",
|
30 |
"warm atmosphere, at home, bedroom": "Set very warm color temperature. Reduce brightness moderately. Add soft diffused lighting. Increase red and yellow tones. Create minimal shadows.",
|
31 |
"magic lit": "Add subtle colored rim lighting in purple and blue tones. Increase brightness selectively on edges. Add soft glow effects. Create ethereal light sources with no clear origin.",
|
|
|
79 |
"soft, diffused foggy glow": "Add volumetric fog throughout scene. Reduce contrast substantially. Create soft lighting with no harsh shadows. Set neutral color temperature.",
|
80 |
"underwater luminescence": "Set blue-green color temperature. Add bioluminescent glowing effects. Create caustic light patterns. Add particle effects in water.",
|
81 |
"rain-soaked reflections in city lights": "Add reflections on wet surfaces. Create light streaking effects. Set urban lighting with multiple colored sources. Add rain particle effects.",
|
82 |
+
"golden time": "add warm golden hour lighting with soft, diffused sunlight creating a magical glow, enhanced contrast, and rich warm tones throughout the scene",
|
83 |
"golden sunlight streaming through trees": "Add god rays effect. Set golden color temperature. Create dappled light patterns. Add atmospheric particles in light beams.",
|
84 |
"fireflies lighting up a summer night": "Add small glowing points of light. Set warm color temperature. Create subtle animated glow effects. Maintain dark ambient lighting.",
|
85 |
"glowing embers from a forge": "Add orange-red glowing particle effects. Set very warm color temperature. Create intense heat glow. Add sparking effects.",
|
|
|
92 |
}
|
93 |
|
94 |
@spaces.GPU
|
95 |
+
def infer(input_image, prompt, illumination_dropdown, seed=42, randomize_seed=False, guidance_scale=2.5, progress=gr.Progress(track_tqdm=True)):
|
96 |
|
97 |
if randomize_seed:
|
98 |
seed = random.randint(0, MAX_SEED)
|
|
|
131 |
with gr.Column(elem_id="col-container"):
|
132 |
gr.Markdown(f"""# FLUX.1 Kontext [dev] Relight 💡
|
133 |
""")
|
134 |
+
gr.Markdown(f"""Kontext[dev] finetuned for scene relighting ✨
|
135 |
""")
|
136 |
|
137 |
with gr.Row():
|
138 |
with gr.Column():
|
139 |
input_image = gr.Image(label="Upload the image for relighting", type="pil")
|
140 |
+
prompt = gr.Textbox(
|
141 |
+
label="prompt",
|
142 |
+
show_label=True,
|
143 |
+
max_lines=3,
|
144 |
+
placeholder="Select an illumination style above or enter your custom description...",
|
145 |
+
value="bright natural sunlight streaming through a window, creating warm golden beams and soft shadows across the scene, with high contrast between lit and shadowed areas",
|
146 |
+
container=True
|
147 |
+
)
|
148 |
# Illumination options dropdown
|
149 |
illumination_dropdown = gr.Dropdown(
|
150 |
choices=list(ILLUMINATION_OPTIONS.keys()) + ["Custom"],
|
|
|
153 |
info="Select a predefined lighting style or choose 'Custom' to use your own prompt"
|
154 |
)
|
155 |
|
156 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
run_button = gr.Button("Run", scale=0, variant="primary")
|
159 |
|
|
|
203 |
gr.on(
|
204 |
triggers=[run_button.click, prompt.submit],
|
205 |
fn = infer,
|
206 |
+
inputs = [input_image, prompt, illumination_dropdown, seed, randomize_seed, guidance_scale],
|
207 |
outputs = [result, seed]
|
208 |
)
|
209 |
|