Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +131 -35
- presets.json +32 -3
app.py
CHANGED
|
@@ -1,42 +1,138 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
-
import json
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
"
|
| 8 |
-
"
|
| 9 |
-
"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
-
|
| 28 |
-
mj_versions = ["6", "6.1", "7"]
|
| 29 |
light_conditions = [
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
]
|
|
|
|
| 33 |
|
| 34 |
-
def
|
| 35 |
-
return gr.update(choices=
|
| 36 |
|
| 37 |
def toggle_visibility(engine):
|
| 38 |
visible = engine == "Midjourney"
|
| 39 |
-
return gr.update(visible=visible)
|
| 40 |
|
| 41 |
def generate_prompt(engine, mj_version, camera, lens, film, light, aspect_ratio, quality, stylize, seed, scene, num):
|
| 42 |
mj_args = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
|
|
@@ -45,9 +141,9 @@ def generate_prompt(engine, mj_version, camera, lens, film, light, aspect_ratio,
|
|
| 45 |
prompts = []
|
| 46 |
for _ in range(num):
|
| 47 |
if engine == "Midjourney":
|
| 48 |
-
prompt = "{}, shot with {} and {}, using {} film, under {} {} --v {}"
|
| 49 |
else:
|
| 50 |
-
prompt = "A detailed scene of {}, captured using a {} and {}, simulated with {} film look and {} lighting."
|
| 51 |
prompts.append(prompt)
|
| 52 |
return "\n".join(prompts)
|
| 53 |
|
|
@@ -57,8 +153,8 @@ with gr.Blocks() as demo:
|
|
| 57 |
engine_choice = gr.Radio(choices=["Midjourney", "ChatGPT Sora"], label="Select Target Engine", value="Midjourney")
|
| 58 |
mj_version_dropdown = gr.Dropdown(choices=mj_versions, label="Midjourney Version", value="7", visible=True)
|
| 59 |
|
| 60 |
-
camera_dropdown = gr.Dropdown(choices=list(
|
| 61 |
-
|
| 62 |
film_dropdown = gr.Dropdown(choices=[], label="Color Film Type")
|
| 63 |
light_dropdown = gr.Dropdown(choices=light_conditions, label="Light Condition")
|
| 64 |
|
|
@@ -73,10 +169,10 @@ with gr.Blocks() as demo:
|
|
| 73 |
output = gr.Textbox(label="Generated Prompts", lines=20)
|
| 74 |
generate_btn = gr.Button("Generate Prompts")
|
| 75 |
|
| 76 |
-
camera_dropdown.change(fn=
|
| 77 |
engine_choice.change(fn=toggle_visibility, inputs=engine_choice, outputs=[mj_version_dropdown, aspect_ratio, quality, stylize])
|
| 78 |
generate_btn.click(fn=generate_prompt, inputs=[
|
| 79 |
-
engine_choice, mj_version_dropdown, camera_dropdown,
|
| 80 |
light_dropdown, aspect_ratio, quality, stylize, seed, scene, num
|
| 81 |
], outputs=output)
|
| 82 |
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
+
camera_lens_map = {
|
| 5 |
+
"Canon EOS R5": [
|
| 6 |
+
"Canon RF 50mm f/1.2L USM",
|
| 7 |
+
"Canon RF 35mm f/1.8 IS Macro STM",
|
| 8 |
+
"Canon RF 85mm f/1.2L USM"
|
| 9 |
+
],
|
| 10 |
+
"Nikon Z8": [
|
| 11 |
+
"Nikon Z 50mm f/1.2 S",
|
| 12 |
+
"Nikon Z 85mm f/1.8 S",
|
| 13 |
+
"Nikon Z 24-70mm f/2.8 S"
|
| 14 |
+
],
|
| 15 |
+
"Sony Alpha 7R V": [
|
| 16 |
+
"Sony FE 85mm f/1.4 GM",
|
| 17 |
+
"Sony FE 24-70mm f/2.8 GM II",
|
| 18 |
+
"Sony FE 50mm f/1.2 GM"
|
| 19 |
+
],
|
| 20 |
+
"Fujifilm GFX 100 II": [
|
| 21 |
+
"Fujifilm GF 80mm f/1.7 R WR",
|
| 22 |
+
"Fujifilm GF 45mm f/2.8 R WR",
|
| 23 |
+
"Fujifilm GF 110mm f/2 R LM WR"
|
| 24 |
+
],
|
| 25 |
+
"Leica M11": [
|
| 26 |
+
"Leica Summilux-M 50mm f/1.4 ASPH",
|
| 27 |
+
"Leica APO-Summicron-M 75mm f/2 ASPH",
|
| 28 |
+
"Leica Elmarit-M 28mm f/2.8 ASPH"
|
| 29 |
+
],
|
| 30 |
+
"Panasonic Lumix S5II": [
|
| 31 |
+
"Panasonic Lumix S Pro 50mm f/1.4",
|
| 32 |
+
"Sigma 35mm f/1.4 DG DN",
|
| 33 |
+
"Panasonic Lumix S 85mm f/1.8"
|
| 34 |
+
],
|
| 35 |
+
"Olympus OM-D E-M1 Mark III": [
|
| 36 |
+
"Olympus M.Zuiko Digital ED 45mm f/1.2 PRO",
|
| 37 |
+
"Olympus M.Zuiko Digital ED 25mm f/1.2 PRO",
|
| 38 |
+
"Olympus M.Zuiko Digital ED 12-40mm f/2.8 PRO"
|
| 39 |
+
],
|
| 40 |
+
"Pentax K-3 Mark III": [
|
| 41 |
+
"HD Pentax-D FA* 50mm f/1.4 SDM AW",
|
| 42 |
+
"HD Pentax-DA 16-85mm f/3.5-5.6 ED DC WR",
|
| 43 |
+
"HD Pentax-D FA 70-210mm f/4 ED SDM WR"
|
| 44 |
+
],
|
| 45 |
+
"Canon EOS 5D Mark IV": [
|
| 46 |
+
"Canon EF 24-70mm f/2.8L II USM",
|
| 47 |
+
"Canon EF 70-200mm f/2.8L IS III USM",
|
| 48 |
+
"Canon EF 50mm f/1.2L USM"
|
| 49 |
+
],
|
| 50 |
+
"Nikon D850": [
|
| 51 |
+
"Nikon AF-S NIKKOR 24-70mm f/2.8E ED VR",
|
| 52 |
+
"Nikon AF-S NIKKOR 105mm f/1.4E ED",
|
| 53 |
+
"Nikon AF-S 50mm f/1.8G"
|
| 54 |
+
],
|
| 55 |
+
"Sony A7 III": [
|
| 56 |
+
"Sony FE 35mm f/1.4 GM",
|
| 57 |
+
"Sony FE 70-200mm f/2.8 GM OSS",
|
| 58 |
+
"Tamron 28-75mm f/2.8 Di III RXD"
|
| 59 |
+
],
|
| 60 |
+
"Fujifilm X-T5": [
|
| 61 |
+
"Fujinon XF 23mm f/1.4 R LM WR",
|
| 62 |
+
"Fujinon XF 56mm f/1.2 R WR",
|
| 63 |
+
"Fujinon XF 16-55mm f/2.8 R LM WR"
|
| 64 |
+
],
|
| 65 |
+
"Leica Q2": [
|
| 66 |
+
"Leica Summilux 28mm f/1.7 ASPH (fixed)",
|
| 67 |
+
"Leica APO-Summicron 90mm f/2 ASPH",
|
| 68 |
+
"Leica Elmarit-M 21mm f/2.8 ASPH"
|
| 69 |
+
],
|
| 70 |
+
"Panasonic GH6": [
|
| 71 |
+
"Panasonic Leica DG 25mm f/1.4 II ASPH",
|
| 72 |
+
"Olympus M.Zuiko ED 75mm f/1.8",
|
| 73 |
+
"Panasonic Lumix 42.5mm f/1.7"
|
| 74 |
+
],
|
| 75 |
+
"Olympus PEN-F": [
|
| 76 |
+
"Olympus M.Zuiko 17mm f/1.8",
|
| 77 |
+
"Olympus M.Zuiko 45mm f/1.8",
|
| 78 |
+
"Olympus M.Zuiko 25mm f/1.8"
|
| 79 |
+
],
|
| 80 |
+
"Pentax 645Z": [
|
| 81 |
+
"Pentax D FA 645 55mm f/2.8 AL",
|
| 82 |
+
"Pentax FA 645 150mm f/2.8",
|
| 83 |
+
"Pentax FA 645 75mm f/2.8"
|
| 84 |
+
],
|
| 85 |
+
"Canon EOS R6 Mark II": [
|
| 86 |
+
"Canon RF 24-105mm f/4L IS USM",
|
| 87 |
+
"Canon RF 85mm f/2 Macro IS STM",
|
| 88 |
+
"Canon RF 70-200mm f/2.8L IS USM"
|
| 89 |
+
],
|
| 90 |
+
"Nikon Z9": [
|
| 91 |
+
"Nikon Z 24-120mm f/4 S",
|
| 92 |
+
"Nikon Z 400mm f/2.8 TC VR S",
|
| 93 |
+
"Nikon Z 70-200mm f/2.8 VR S"
|
| 94 |
+
],
|
| 95 |
+
"Sony FX3": [
|
| 96 |
+
"Sony FE 24mm f/1.4 GM",
|
| 97 |
+
"Sony FE PZ 28-135mm f/4 G OSS",
|
| 98 |
+
"Sigma 85mm f/1.4 DG DN Art"
|
| 99 |
+
],
|
| 100 |
+
"Fujifilm X-H2": [
|
| 101 |
+
"Fujinon XF 18mm f/1.4 R LM WR",
|
| 102 |
+
"Fujinon XF 33mm f/1.4 R LM WR",
|
| 103 |
+
"Fujinon XF 56mm f/1.2 R APD"
|
| 104 |
+
]
|
| 105 |
}
|
|
|
|
|
|
|
| 106 |
light_conditions = [
|
| 107 |
+
"Golden Hour",
|
| 108 |
+
"Blue Hour",
|
| 109 |
+
"Backlighting",
|
| 110 |
+
"Overcast Light",
|
| 111 |
+
"High Noon Sunlight",
|
| 112 |
+
"Twilight Glow",
|
| 113 |
+
"Morning Fog",
|
| 114 |
+
"Studio Lighting",
|
| 115 |
+
"Soft Ambient Light",
|
| 116 |
+
"Window Light",
|
| 117 |
+
"Dappled Light",
|
| 118 |
+
"Hard Shadow",
|
| 119 |
+
"Spotlight",
|
| 120 |
+
"Stage Lighting",
|
| 121 |
+
"Silhouette Light",
|
| 122 |
+
"Fluorescent Light",
|
| 123 |
+
"Candlelight",
|
| 124 |
+
"Moonlight",
|
| 125 |
+
"Streetlight Glow",
|
| 126 |
+
"Reflected Light"
|
| 127 |
]
|
| 128 |
+
mj_versions = ["6", "6.1", "7"]
|
| 129 |
|
| 130 |
+
def update_lens_dropdown(camera):
|
| 131 |
+
return gr.update(choices=camera_lens_map[camera], value=camera_lens_map[camera][0])
|
| 132 |
|
| 133 |
def toggle_visibility(engine):
|
| 134 |
visible = engine == "Midjourney"
|
| 135 |
+
return [gr.update(visible=visible)] * 4
|
| 136 |
|
| 137 |
def generate_prompt(engine, mj_version, camera, lens, film, light, aspect_ratio, quality, stylize, seed, scene, num):
|
| 138 |
mj_args = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
|
|
|
|
| 141 |
prompts = []
|
| 142 |
for _ in range(num):
|
| 143 |
if engine == "Midjourney":
|
| 144 |
+
prompt = f"{scene}, shot with {camera} and {lens}, using {film} film, under {light} {mj_args} --v {mj_version}"
|
| 145 |
else:
|
| 146 |
+
prompt = f"A detailed scene of {scene}, captured using a {camera} and {lens}, simulated with {film} film look and {light} lighting."
|
| 147 |
prompts.append(prompt)
|
| 148 |
return "\n".join(prompts)
|
| 149 |
|
|
|
|
| 153 |
engine_choice = gr.Radio(choices=["Midjourney", "ChatGPT Sora"], label="Select Target Engine", value="Midjourney")
|
| 154 |
mj_version_dropdown = gr.Dropdown(choices=mj_versions, label="Midjourney Version", value="7", visible=True)
|
| 155 |
|
| 156 |
+
camera_dropdown = gr.Dropdown(choices=list(camera_lens_map.keys()), label="Camera Model")
|
| 157 |
+
lens_dropdown = gr.Dropdown(choices=[], label="Lens Model")
|
| 158 |
film_dropdown = gr.Dropdown(choices=[], label="Color Film Type")
|
| 159 |
light_dropdown = gr.Dropdown(choices=light_conditions, label="Light Condition")
|
| 160 |
|
|
|
|
| 169 |
output = gr.Textbox(label="Generated Prompts", lines=20)
|
| 170 |
generate_btn = gr.Button("Generate Prompts")
|
| 171 |
|
| 172 |
+
camera_dropdown.change(fn=update_lens_dropdown, inputs=camera_dropdown, outputs=lens_dropdown)
|
| 173 |
engine_choice.change(fn=toggle_visibility, inputs=engine_choice, outputs=[mj_version_dropdown, aspect_ratio, quality, stylize])
|
| 174 |
generate_btn.click(fn=generate_prompt, inputs=[
|
| 175 |
+
engine_choice, mj_version_dropdown, camera_dropdown, lens_dropdown, film_dropdown,
|
| 176 |
light_dropdown, aspect_ratio, quality, stylize, seed, scene, num
|
| 177 |
], outputs=output)
|
| 178 |
|
presets.json
CHANGED
|
@@ -1,5 +1,34 @@
|
|
| 1 |
{
|
| 2 |
-
"Sunset
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"Sunset Portrait": {
|
| 3 |
+
"camera": "Canon EOS R5",
|
| 4 |
+
"lens": "Canon RF 50mm f/1.2L USM",
|
| 5 |
+
"film": "Kodak Portra 400",
|
| 6 |
+
"light": "Golden Hour",
|
| 7 |
+
"scene": "A woman standing in a field of tall grass during sunset, soft wind in her hair",
|
| 8 |
+
"version": "7"
|
| 9 |
+
},
|
| 10 |
+
"Urban Streetstyle": {
|
| 11 |
+
"camera": "Sony Alpha 7R V",
|
| 12 |
+
"lens": "Sony FE 85mm f/1.4 GM",
|
| 13 |
+
"film": "Kodak Ultramax 400",
|
| 14 |
+
"light": "Backlighting",
|
| 15 |
+
"scene": "Young man walking through a neon-lit city street at night with glowing billboards",
|
| 16 |
+
"version": "6.1"
|
| 17 |
+
},
|
| 18 |
+
"Forest Fantasy": {
|
| 19 |
+
"camera": "Fujifilm GFX 100 II",
|
| 20 |
+
"lens": "Fujifilm GF 80mm f/1.7 R WR",
|
| 21 |
+
"film": "Fujifilm Provia 100F",
|
| 22 |
+
"light": "Diffused Light",
|
| 23 |
+
"scene": "A mysterious elf walking through a foggy forest with glowing mushrooms",
|
| 24 |
+
"version": "6"
|
| 25 |
+
},
|
| 26 |
+
"Classic Black and White": {
|
| 27 |
+
"camera": "Leica M11",
|
| 28 |
+
"lens": "Leica Summilux-M 50mm f/1.4 ASPH",
|
| 29 |
+
"film": "Ilford HP5 Plus",
|
| 30 |
+
"light": "Soft Ambient Light",
|
| 31 |
+
"scene": "Man reading newspaper in a Parisian caf\u00e9, 1950s",
|
| 32 |
+
"version": "7"
|
| 33 |
+
}
|
| 34 |
}
|