TischEins commited on
Commit
fdedd0d
·
verified ·
1 Parent(s): 323eec0

Upload 3 files

Browse files
Files changed (2) hide show
  1. app.py +131 -35
  2. presets.json +32 -3
app.py CHANGED
@@ -1,42 +1,138 @@
1
 
2
  import gradio as gr
3
- import json
4
 
5
- camera_film_map = {
6
- "Canon EOS R5": ["Kodak Portra 400", "Kodak Ektar 100", "Kodak Gold 200"],
7
- "Nikon Z8": ["Cinestill 800T", "Kodak Tri-X 400", "Fujifilm Superia X-TRA 400"],
8
- "Sony Alpha 7R V": ["Agfa Vista 200", "Kodak Ultramax 400", "Fujifilm C200"],
9
- "Fujifilm GFX 100 II": ["Fujifilm Pro 400H", "Fujifilm Provia 100F", "Fujifilm Velvia 50"],
10
- "Leica M11": ["Ilford HP5 Plus", "Kodak T-Max 100", "AgfaPhoto APX 100"],
11
- "Panasonic Lumix S5II": ["Kodak Vision3 500T", "Cinestill 50D", "Kodak Gold 200"],
12
- "Olympus OM-D E-M1 Mark III": ["Kodak Ektachrome E100", "Fujifilm Neopan 100", "Kodak ColorPlus 200"],
13
- "Pentax K-3 Mark III": ["Ilford Delta 3200", "Fomapan 100 Classic", "Rollei Retro 400S"],
14
- "Canon EOS 5D Mark IV": ["Kodak Pro Image 100", "Kodak Vision3 250D", "Fujicolor 100"],
15
- "Nikon D850": ["AgfaPhoto Vista plus 400", "Fujicolor Industrial 100", "Kodak T-Max 400"],
16
- "Sony A7 III": ["Cinestill BwXX", "Kodak Gold 100", "Fujifilm Natura 1600"],
17
- "Fujifilm X-T5": ["Fujifilm Pro 160NS", "Kodak Elite Chrome 100", "Fujifilm Fortia SP"],
18
- "Leica Q2": ["Ilford XP2 Super 400", "Kodak ColorPlus 100", "Fujicolor Press 800"],
19
- "Panasonic GH6": ["Agfa Scala 200x", "Kodak High-Speed Infrared", "Rollei Vario Chrome"],
20
- "Olympus PEN-F": ["Fujifilm Sensia 200", "Kodak Ektachrome 64T", "Kodak Supra 400"],
21
- "Pentax 645Z": ["Kodak Panatomic-X", "Agfa Portrait XPS 160", "Kodak Vericolor III"],
22
- "Canon EOS R6 Mark II": ["Kodak Vision3 200T", "Kodak Gold 400", "Ilford Pan F Plus 50"],
23
- "Nikon Z9": ["Fujifilm Velvia 100", "Kodak Ektachrome 160", "Ilford Delta 100"],
24
- "Sony FX3": ["Kodak Vision3 500D", "Cinestill 400D", "Fujifilm Provia 400X"],
25
- "Fujifilm X-H2": ["Kodak Technical Pan", "AgfaPhoto CT Precisa 100", "Fujifilm Velvia 100F"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
-
28
- mj_versions = ["6", "6.1", "7"]
29
  light_conditions = [
30
- "Golden Hour", "Blue Hour", "Overcast Light", "Diffused Light", "Backlighting",
31
- "Soft Ambient Light", "Low-Key Lighting", "High-Key Lighting", "Window Light", "Dappled Light"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ]
 
33
 
34
- def update_film_dropdown(camera):
35
- return gr.update(choices=camera_film_map[camera], value=camera_film_map[camera][0])
36
 
37
  def toggle_visibility(engine):
38
  visible = engine == "Midjourney"
39
- return gr.update(visible=visible), gr.update(visible=visible), gr.update(visible=visible), 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 {}".format(scene, camera, lens, film, light, mj_args, mj_version)
49
  else:
50
- prompt = "A detailed scene of {}, captured using a {} and {}, simulated with {} film look and {} lighting.".format(scene, camera, lens, film, light)
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(camera_film_map.keys()), label="Camera Model")
61
- lens_input = gr.Textbox(label="Lens Model")
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=update_film_dropdown, inputs=camera_dropdown, outputs=film_dropdown)
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, lens_input, film_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 Cityscape": "A glowing city skyline at sunset with long shadows and neon signs",
3
- "Fantasy Forest": "A lush magical forest filled with glowing plants and fairy lights",
4
- "Retro Diner": "An American 50s-style diner with neon lights and chrome surfaces"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  }