Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
app.py
CHANGED
|
@@ -229,6 +229,40 @@ light_conditions = [
|
|
| 229 |
"Reflected Light"
|
| 230 |
]
|
| 231 |
mj_versions = ["6", "6.1", "7"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
def update_lens_dropdown(camera):
|
| 234 |
return gr.update(choices=camera_lens_map[camera], value=camera_lens_map[camera][0])
|
|
@@ -240,6 +274,17 @@ def toggle_visibility(engine):
|
|
| 240 |
visible = engine == "Midjourney"
|
| 241 |
return [gr.update(visible=visible)] * 4
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def generate_prompt(engine, mj_version, camera, lens, film, light, aspect_ratio, quality, stylize, seed, scene, num):
|
| 244 |
mj_args = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
|
| 245 |
if seed:
|
|
@@ -266,12 +311,14 @@ def export_to_csv(prompts):
|
|
| 266 |
with gr.Blocks() as demo:
|
| 267 |
gr.Markdown("# TischEins.org | Midjourney Prompt Engine")
|
| 268 |
|
|
|
|
|
|
|
| 269 |
engine_choice = gr.Radio(choices=["Midjourney", "ChatGPT Sora"], label="Select Target Engine", value="Midjourney")
|
| 270 |
mj_version_dropdown = gr.Dropdown(choices=mj_versions, label="Midjourney Version", value="7", visible=True)
|
| 271 |
|
| 272 |
-
camera_dropdown = gr.Dropdown(choices=list(camera_lens_map.keys()), label="Camera Model")
|
| 273 |
-
lens_dropdown = gr.Dropdown(choices=[], label="Lens Model")
|
| 274 |
-
film_dropdown = gr.Dropdown(choices=[], label="Color Film Type")
|
| 275 |
light_dropdown = gr.Dropdown(choices=light_conditions, label="Light Condition")
|
| 276 |
|
| 277 |
aspect_ratio = gr.Textbox(label="Aspect Ratio", value="5:4", visible=True)
|
|
@@ -291,9 +338,14 @@ with gr.Blocks() as demo:
|
|
| 291 |
download_txt = gr.File(visible=False)
|
| 292 |
download_csv = gr.File(visible=False)
|
| 293 |
|
|
|
|
|
|
|
|
|
|
| 294 |
camera_dropdown.change(fn=update_lens_dropdown, inputs=camera_dropdown, outputs=lens_dropdown)
|
| 295 |
camera_dropdown.change(fn=update_film_dropdown, inputs=camera_dropdown, outputs=film_dropdown)
|
| 296 |
-
engine_choice.change(fn=toggle_visibility, inputs=engine_choice, outputs=[
|
|
|
|
|
|
|
| 297 |
|
| 298 |
generate_btn.click(fn=generate_prompt, inputs=[
|
| 299 |
engine_choice, mj_version_dropdown, camera_dropdown, lens_dropdown, film_dropdown,
|
|
|
|
| 229 |
"Reflected Light"
|
| 230 |
]
|
| 231 |
mj_versions = ["6", "6.1", "7"]
|
| 232 |
+
presets = {
|
| 233 |
+
"Sunset Portrait": {
|
| 234 |
+
"camera": "Canon EOS R5",
|
| 235 |
+
"lens": "Canon RF 50mm f/1.2L USM",
|
| 236 |
+
"film": "Kodak Portra 400",
|
| 237 |
+
"light": "Golden Hour",
|
| 238 |
+
"scene": "A woman standing in a field of tall grass during sunset, soft wind in her hair",
|
| 239 |
+
"version": "7"
|
| 240 |
+
},
|
| 241 |
+
"Urban Streetstyle": {
|
| 242 |
+
"camera": "Sony Alpha 7R V",
|
| 243 |
+
"lens": "Sony FE 85mm f/1.4 GM",
|
| 244 |
+
"film": "Kodak Ultramax 400",
|
| 245 |
+
"light": "Backlighting",
|
| 246 |
+
"scene": "Young man walking through a neon-lit city street at night with glowing billboards",
|
| 247 |
+
"version": "6.1"
|
| 248 |
+
},
|
| 249 |
+
"Forest Fantasy": {
|
| 250 |
+
"camera": "Fujifilm GFX 100 II",
|
| 251 |
+
"lens": "Fujifilm GF 80mm f/1.7 R WR",
|
| 252 |
+
"film": "Fujifilm Provia 100F",
|
| 253 |
+
"light": "Diffused Light",
|
| 254 |
+
"scene": "A mysterious elf walking through a foggy forest with glowing mushrooms",
|
| 255 |
+
"version": "6"
|
| 256 |
+
},
|
| 257 |
+
"Classic Black and White": {
|
| 258 |
+
"camera": "Leica M11",
|
| 259 |
+
"lens": "Leica Summilux-M 50mm f/1.4 ASPH",
|
| 260 |
+
"film": "Ilford HP5 Plus",
|
| 261 |
+
"light": "Soft Ambient Light",
|
| 262 |
+
"scene": "Man reading newspaper in a Parisian caf\u00e9, 1950s",
|
| 263 |
+
"version": "7"
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
|
| 267 |
def update_lens_dropdown(camera):
|
| 268 |
return gr.update(choices=camera_lens_map[camera], value=camera_lens_map[camera][0])
|
|
|
|
| 274 |
visible = engine == "Midjourney"
|
| 275 |
return [gr.update(visible=visible)] * 4
|
| 276 |
|
| 277 |
+
def apply_preset(preset_name):
|
| 278 |
+
preset = presets[preset_name]
|
| 279 |
+
return (
|
| 280 |
+
preset["camera"],
|
| 281 |
+
camera_lens_map[preset["camera"]][0],
|
| 282 |
+
camera_film_map[preset["camera"]][0],
|
| 283 |
+
preset["light"],
|
| 284 |
+
preset["scene"],
|
| 285 |
+
preset["version"]
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
def generate_prompt(engine, mj_version, camera, lens, film, light, aspect_ratio, quality, stylize, seed, scene, num):
|
| 289 |
mj_args = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
|
| 290 |
if seed:
|
|
|
|
| 311 |
with gr.Blocks() as demo:
|
| 312 |
gr.Markdown("# TischEins.org | Midjourney Prompt Engine")
|
| 313 |
|
| 314 |
+
preset_selector = gr.Dropdown(choices=['Sunset Portrait', 'Urban Streetstyle', 'Forest Fantasy', 'Classic Black and White'], label="Select Preset")
|
| 315 |
+
|
| 316 |
engine_choice = gr.Radio(choices=["Midjourney", "ChatGPT Sora"], label="Select Target Engine", value="Midjourney")
|
| 317 |
mj_version_dropdown = gr.Dropdown(choices=mj_versions, label="Midjourney Version", value="7", visible=True)
|
| 318 |
|
| 319 |
+
camera_dropdown = gr.Dropdown(choices=list(camera_lens_map.keys()), label="Camera Model", value=list(camera_lens_map.keys())[0])
|
| 320 |
+
lens_dropdown = gr.Dropdown(choices=camera_lens_map[list(camera_lens_map.keys())[0]], label="Lens Model")
|
| 321 |
+
film_dropdown = gr.Dropdown(choices=camera_film_map[list(camera_film_map.keys())[0]], label="Color Film Type")
|
| 322 |
light_dropdown = gr.Dropdown(choices=light_conditions, label="Light Condition")
|
| 323 |
|
| 324 |
aspect_ratio = gr.Textbox(label="Aspect Ratio", value="5:4", visible=True)
|
|
|
|
| 338 |
download_txt = gr.File(visible=False)
|
| 339 |
download_csv = gr.File(visible=False)
|
| 340 |
|
| 341 |
+
preset_selector.change(fn=apply_preset, inputs=preset_selector, outputs=[
|
| 342 |
+
camera_dropdown, lens_dropdown, film_dropdown, light_dropdown, scene, mj_version_dropdown
|
| 343 |
+
])
|
| 344 |
camera_dropdown.change(fn=update_lens_dropdown, inputs=camera_dropdown, outputs=lens_dropdown)
|
| 345 |
camera_dropdown.change(fn=update_film_dropdown, inputs=camera_dropdown, outputs=film_dropdown)
|
| 346 |
+
engine_choice.change(fn=toggle_visibility, inputs=engine_choice, outputs=[
|
| 347 |
+
mj_version_dropdown, aspect_ratio, quality, stylize
|
| 348 |
+
])
|
| 349 |
|
| 350 |
generate_btn.click(fn=generate_prompt, inputs=[
|
| 351 |
engine_choice, mj_version_dropdown, camera_dropdown, lens_dropdown, film_dropdown,
|