TischEins commited on
Commit
fa32687
·
verified ·
1 Parent(s): 58d514c

Upload 3 files

Browse files
Files changed (2) hide show
  1. app.py +38 -54
  2. presets.json +144 -16
app.py CHANGED
@@ -7,91 +7,75 @@ import json
7
  with open("presets.json") as f:
8
  presets = json.load(f)
9
 
10
- camera_lens_map = {
11
- "Canon EOS R5": ["Canon RF 50mm f/1.2L USM", "Canon RF 35mm f/1.8 IS Macro STM", "Canon RF 85mm f/1.2L USM"],
12
- "Sony Alpha 7R V": ["Sony FE 85mm f/1.4 GM", "Sony FE 24-70mm f/2.8 GM II", "Sony FE 50mm f/1.2 GM"],
13
- "Fujifilm GFX 100 II": ["Fujifilm GF 80mm f/1.7 R WR", "Fujifilm GF 45mm f/2.8 R WR", "Fujifilm GF 110mm f/2 R LM WR"],
14
- "Leica M11": ["Leica Summilux-M 50mm f/1.4 ASPH", "Leica APO-Summicron-M 75mm f/2 ASPH", "Leica Elmarit-M 28mm f/2.8 ASPH"]
15
- }
16
- camera_film_map = {
17
- "Canon EOS R5": ["Kodak Portra 400", "Kodak Ektar 100", "Kodak Gold 200"],
18
- "Sony Alpha 7R V": ["Agfa Vista 200", "Kodak Ultramax 400", "Fujifilm C200"],
19
- "Fujifilm GFX 100 II": ["Fujifilm Provia 100F", "Fujifilm Velvia 50", "Fujifilm Pro 400H"],
20
- "Leica M11": ["Ilford HP5 Plus", "Kodak T-Max 100", "AgfaPhoto APX 100"]
21
- }
22
- light_conditions = [
23
- "Golden Hour","Blue Hour","Backlighting","Overcast Light","High Noon Sunlight",
24
- "Twilight Glow","Morning Fog","Studio Lighting","Soft Ambient Light","Window Light",
25
- "Dappled Light","Hard Shadow","Spotlight","Stage Lighting","Silhouette Light",
26
- "Fluorescent Light","Candlelight","Moonlight","Streetlight Glow","Reflected Light"
27
- ]
28
- scene_variations = [
29
- "with dramatic lens flare","with soft bokeh background","with rich cinematic contrast",
30
- "with muted pastel tones","with vibrant color pop","with deep shadows","with high-key brightness",
31
- "with low-key mood","with subtle grain texture","with glossy reflections"
32
- ]
33
 
34
- def update_lens(camera):
35
- return gr.update(choices=camera_lens_map.get(camera, []), value=camera_lens_map.get(camera, [None])[0])
 
36
 
37
- def update_film(camera):
38
- return gr.update(choices=camera_film_map.get(camera, []), value=camera_film_map.get(camera, [None])[0])
 
39
 
40
- def generate_mid(img_camera, img_lens, img_film, img_light, mj_version, ar, q, s, seed, scene, num):
41
  prompts=[]
42
- varsamples = random.sample(scene_variations, num)
43
  for i in range(num):
44
- sc = f"{scene}, {varsamples[i]}"
 
45
  args = f"--ar {ar} --q {q} --s {s}" + (f" --seed {seed}" if seed else "")
46
- prompts.append(f"{sc}, shot with {img_camera} and {img_lens}, using {img_film} film, under {img_light} {args} --v {mj_version}")
47
  return "\n".join(prompts), prompts
48
 
49
- def generate_sora(img_camera, img_lens, img_film, img_light, scene):
50
  var = random.choice(scene_variations)
51
  sc = f"{scene}, {var}"
52
- prompt = f"A detailed scene of {sc}, captured using a {img_camera} and {img_lens}, simulated with {img_film} film look and {img_light} lighting."
53
- return prompt, [prompt]
54
 
55
  def export_txt(prompts):
56
- with open("prompts.txt","w") as f:
57
- f.write("\n".join(prompts))
58
  return gr.File.update(value="prompts.txt")
59
 
60
  def export_csv(prompts):
61
- df = pd.DataFrame({"Prompt":prompts})
62
  df.to_csv("prompts.csv", index=False)
63
  return gr.File.update(value="prompts.csv")
64
 
65
  with gr.Blocks() as demo:
66
  gr.Markdown("## TischEins.org | Midjourney Prompt Engine\nPro Studio Prompt Generator for Midjourney and Sora")
 
 
 
 
 
 
 
 
 
67
  with gr.Tab("Midjourney"):
68
- preset = gr.Dropdown(list(presets.keys()), label="Select Preset")
69
- camera = gr.Dropdown(list(camera_lens_map.keys()), label="Camera Model")
70
- lens = gr.Dropdown([], label="Lens Model")
71
- film = gr.Dropdown([], label="Color Film Type")
72
- light = gr.Dropdown(light_conditions, label="Light Condition")
73
- mjv = gr.Dropdown(["6","6.1","7"], label="Midjourney Version", value="7")
74
  ar = gr.Textbox(label="Aspect Ratio", value="5:4")
75
  q = gr.Textbox(label="Quality", value="2")
76
  s = gr.Textbox(label="Stylize", value="0")
77
  seed = gr.Textbox(label="Seed (optional)")
78
- scene = gr.Textbox(label="Scene Description")
79
- num = gr.Slider(1,5,3,label="Number of Prompts")
80
- out, state = gr.Textbox(lines=5), gr.State([])
81
- btn = gr.Button("Generate")
82
- btn.click(generate_mid, [camera, lens, film, light, mjv, ar, q, s, seed, scene, num], [out, state])
83
  txtb = gr.Button("Export TXT"); csvb = gr.Button("Export CSV")
84
  dtxt = gr.File(visible=False); dcsv = gr.File(visible=False)
85
- txtb.click(export_txt, state, dtxt); csvb.click(export_csv, state, dcsv)
86
- camera.change(update_lens, camera, lens); camera.change(update_film, camera, film)
87
  with gr.Tab("ChatGPT Sora"):
88
- scene_s = gr.Textbox(label="Scene Description")
89
  out_s, state_s = gr.Textbox(lines=5), gr.State([])
90
- btn_s = gr.Button("Generate")
91
- btn_s.click(generate_sora, [camera, lens, film, light, scene_s], [out_s, state_s])
92
  txt_s = gr.Button("Export TXT"); csv_s = gr.Button("Export CSV")
93
  dtxt_s = gr.File(visible=False); dcsv_s = gr.File(visible=False)
94
  txt_s.click(export_txt, state_s, dtxt_s); csv_s.click(export_csv, state_s, dcsv_s)
95
- camera.change(update_lens, camera, lens); camera.change(update_film, camera, film)
96
  gr.Markdown('<a href="https://tischeins.org">Pro Studio Mode by TischEins.org</a>')
97
  demo.launch()
 
7
  with open("presets.json") as f:
8
  presets = json.load(f)
9
 
10
+ camera_lens_map = presets # placeholders
11
+ # rebuild camera_lens_map and camera_film_map from presets
12
+ camera_lens_map = {p: [presets[p]['lens']] for p in presets}
13
+ camera_film_map = {p: [presets[p]['film']] for p in presets}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ light_conditions = list({p: presets[p]['light'] for p in presets}.values())
16
+ mj_versions = ["6","6.1","7"]
17
+ scene_variations = ["with dramatic lens flare","with soft bokeh background"] * 10
18
 
19
+ def apply_preset(p):
20
+ pre = presets[p]
21
+ return pre['camera'], pre['lens'], pre['film'], pre['light'], pre['scene']
22
 
23
+ def generate_mid(camera, lens, film, light, mjv, ar, q, s, seed, scene, num):
24
  prompts=[]
 
25
  for i in range(num):
26
+ var = random.choice(scene_variations)
27
+ sc = f"{scene}, {var}"
28
  args = f"--ar {ar} --q {q} --s {s}" + (f" --seed {seed}" if seed else "")
29
+ prompts.append(f"{sc}, shot with {camera} and {lens}, using {film} film, under {light} {args} --v {mjv}")
30
  return "\n".join(prompts), prompts
31
 
32
+ def generate_sora(camera, lens, film, light, scene):
33
  var = random.choice(scene_variations)
34
  sc = f"{scene}, {var}"
35
+ p = f"A detailed scene of {sc}, captured using a {camera} and {lens}, simulated with {film} film look and {light} lighting."
36
+ return p, [p]
37
 
38
  def export_txt(prompts):
39
+ with open("prompts.txt","w") as f: f.write("\n".join(prompts))
 
40
  return gr.File.update(value="prompts.txt")
41
 
42
  def export_csv(prompts):
43
+ df=pd.DataFrame({"Prompt":prompts})
44
  df.to_csv("prompts.csv", index=False)
45
  return gr.File.update(value="prompts.csv")
46
 
47
  with gr.Blocks() as demo:
48
  gr.Markdown("## TischEins.org | Midjourney Prompt Engine\nPro Studio Prompt Generator for Midjourney and Sora")
49
+ preset = gr.Dropdown(choices=list(presets.keys()), label="Select Preset")
50
+ camera = gr.Dropdown(choices=list(camera_lens_map.keys()), label="Camera Model")
51
+ lens = gr.Dropdown(choices=[], label="Lens Model")
52
+ film = gr.Dropdown(choices=[], label="Color Film Type")
53
+ light = gr.Dropdown(choices=light_conditions, label="Light Condition")
54
+ preset.change(fn=apply_preset, inputs=preset, outputs=[camera, lens, film, light, scene := gr.Textbox(label="Scene Description")])
55
+ camera.change(fn=lambda x: gr.update(choices=camera_lens_map[x]), inputs=camera, outputs=lens)
56
+ camera.change(fn=lambda x: gr.update(choices=camera_film_map[x]), inputs=camera, outputs=film)
57
+
58
  with gr.Tab("Midjourney"):
59
+ mjv = gr.Dropdown(choices=mj_versions, label="Midjourney Version", value="7")
 
 
 
 
 
60
  ar = gr.Textbox(label="Aspect Ratio", value="5:4")
61
  q = gr.Textbox(label="Quality", value="2")
62
  s = gr.Textbox(label="Stylize", value="0")
63
  seed = gr.Textbox(label="Seed (optional)")
64
+ num = gr.Slider(1,5,value=3,label="Number of Prompts")
65
+ out_mid, state_mid = gr.Textbox(lines=10), gr.State([])
66
+ gen = gr.Button("Generate")
67
+ gen.click(fn=generate_mid, inputs=[camera, lens, film, light, mjv, ar, q, s, seed, scene, num], outputs=[out_mid, state_mid])
 
68
  txtb = gr.Button("Export TXT"); csvb = gr.Button("Export CSV")
69
  dtxt = gr.File(visible=False); dcsv = gr.File(visible=False)
70
+ txtb.click(export_txt, state_mid, dtxt); csvb.click(export_csv, state_mid, dcsv)
71
+
72
  with gr.Tab("ChatGPT Sora"):
 
73
  out_s, state_s = gr.Textbox(lines=5), gr.State([])
74
+ gen_s = gr.Button("Generate")
75
+ gen_s.click(fn=generate_sora, inputs=[camera, lens, film, light, scene], outputs=[out_s, state_s])
76
  txt_s = gr.Button("Export TXT"); csv_s = gr.Button("Export CSV")
77
  dtxt_s = gr.File(visible=False); dcsv_s = gr.File(visible=False)
78
  txt_s.click(export_txt, state_s, dtxt_s); csv_s.click(export_csv, state_s, dcsv_s)
79
+
80
  gr.Markdown('<a href="https://tischeins.org">Pro Studio Mode by TischEins.org</a>')
81
  demo.launch()
presets.json CHANGED
@@ -1,34 +1,162 @@
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
  }
 
1
  {
2
+ "Preset 01": {
3
  "camera": "Canon EOS R5",
4
  "lens": "Canon RF 50mm f/1.2L USM",
5
+ "film": "Canon RF 50mm f/1.2L USM",
6
  "light": "Golden Hour",
7
+ "scene": "Scene description for Canon EOS R5",
8
  "version": "7"
9
  },
10
+ "Preset 02": {
11
+ "camera": "Canon EOS R3",
12
+ "lens": "Canon RF 24-70mm f/2.8L IS USM",
13
+ "film": "Canon RF 24-70mm f/2.8L IS USM",
14
+ "light": "Blue Hour",
15
+ "scene": "Scene description for Canon EOS R3",
16
+ "version": "7"
17
+ },
18
+ "Preset 03": {
19
+ "camera": "Nikon Z8",
20
+ "lens": "Nikon Z 50mm f/1.2 S",
21
+ "film": "Nikon Z 50mm f/1.2 S",
22
+ "light": "Backlighting",
23
+ "scene": "Scene description for Nikon Z8",
24
+ "version": "7"
25
+ },
26
+ "Preset 04": {
27
+ "camera": "Nikon Z9",
28
+ "lens": "Nikon Z 70-200mm f/2.8 VR S",
29
+ "film": "Nikon Z 70-200mm f/2.8 VR S",
30
+ "light": "Overcast Light",
31
+ "scene": "Scene description for Nikon Z9",
32
+ "version": "7"
33
+ },
34
+ "Preset 05": {
35
  "camera": "Sony Alpha 7R V",
36
  "lens": "Sony FE 85mm f/1.4 GM",
37
+ "film": "Sony FE 85mm f/1.4 GM",
38
+ "light": "High Noon Sunlight",
39
+ "scene": "Scene description for Sony Alpha 7R V",
40
+ "version": "7"
41
  },
42
+ "Preset 06": {
43
+ "camera": "Sony Alpha 1",
44
+ "lens": "Sony FE 35mm f/1.4 GM",
45
+ "film": "Sony FE 35mm f/1.4 GM",
46
+ "light": "Twilight Glow",
47
+ "scene": "Scene description for Sony Alpha 1",
48
+ "version": "7"
49
+ },
50
+ "Preset 07": {
51
  "camera": "Fujifilm GFX 100 II",
52
  "lens": "Fujifilm GF 80mm f/1.7 R WR",
53
+ "film": "Fujifilm GF 80mm f/1.7 R WR",
54
+ "light": "Morning Fog",
55
+ "scene": "Scene description for Fujifilm GFX 100 II",
56
+ "version": "7"
57
+ },
58
+ "Preset 08": {
59
+ "camera": "Fujifilm X-T5",
60
+ "lens": "Fujinon XF 56mm f/1.2 R WR",
61
+ "film": "Fujinon XF 56mm f/1.2 R WR",
62
+ "light": "Studio Lighting",
63
+ "scene": "Scene description for Fujifilm X-T5",
64
+ "version": "7"
65
  },
66
+ "Preset 09": {
67
  "camera": "Leica M11",
68
  "lens": "Leica Summilux-M 50mm f/1.4 ASPH",
69
+ "film": "Leica Summilux-M 50mm f/1.4 ASPH",
70
  "light": "Soft Ambient Light",
71
+ "scene": "Scene description for Leica M11",
72
+ "version": "7"
73
+ },
74
+ "Preset 10": {
75
+ "camera": "Leica SL2-S",
76
+ "lens": "Leica APO-Summicron-SL 75mm f/2 ASPH",
77
+ "film": "Leica APO-Summicron-SL 75mm f/2 ASPH",
78
+ "light": "Window Light",
79
+ "scene": "Scene description for Leica SL2-S",
80
+ "version": "7"
81
+ },
82
+ "Preset 11": {
83
+ "camera": "Panasonic Lumix S5 II",
84
+ "lens": "Panasonic Lumix S Pro 24-70mm f/2.8",
85
+ "film": "Panasonic Lumix S Pro 24-70mm f/2.8",
86
+ "light": "Dappled Light",
87
+ "scene": "Scene description for Panasonic Lumix S5 II",
88
+ "version": "7"
89
+ },
90
+ "Preset 12": {
91
+ "camera": "Panasonic GH6",
92
+ "lens": "Panasonic Leica DG Nocticron 42.5mm f/1.2",
93
+ "film": "Panasonic Leica DG Nocticron 42.5mm f/1.2",
94
+ "light": "Hard Shadow",
95
+ "scene": "Scene description for Panasonic GH6",
96
+ "version": "7"
97
+ },
98
+ "Preset 13": {
99
+ "camera": "Hasselblad X2D 100C",
100
+ "lens": "Hasselblad XCD 80mm f/1.9",
101
+ "film": "Hasselblad XCD 80mm f/1.9",
102
+ "light": "Spotlight",
103
+ "scene": "Scene description for Hasselblad X2D 100C",
104
+ "version": "7"
105
+ },
106
+ "Preset 14": {
107
+ "camera": "Olympus OM-1",
108
+ "lens": "Olympus M.Zuiko 25mm f/1.2 PRO",
109
+ "film": "Olympus M.Zuiko 25mm f/1.2 PRO",
110
+ "light": "Stage Lighting",
111
+ "scene": "Scene description for Olympus OM-1",
112
+ "version": "7"
113
+ },
114
+ "Preset 15": {
115
+ "camera": "Olympus PEN-F",
116
+ "lens": "Olympus M.Zuiko 17mm f/1.8",
117
+ "film": "Olympus M.Zuiko 17mm f/1.8",
118
+ "light": "Silhouette Light",
119
+ "scene": "Scene description for Olympus PEN-F",
120
+ "version": "7"
121
+ },
122
+ "Preset 16": {
123
+ "camera": "Pentax K-1 Mark II",
124
+ "lens": "Pentax D FA* 50mm f/1.4 SDM AW",
125
+ "film": "Pentax D FA* 50mm f/1.4 SDM AW",
126
+ "light": "Fluorescent Light",
127
+ "scene": "Scene description for Pentax K-1 Mark II",
128
+ "version": "7"
129
+ },
130
+ "Preset 17": {
131
+ "camera": "Pentax 645Z",
132
+ "lens": "Pentax FA 645 75mm f/2.8",
133
+ "film": "Pentax FA 645 75mm f/2.8",
134
+ "light": "Candlelight",
135
+ "scene": "Scene description for Pentax 645Z",
136
+ "version": "7"
137
+ },
138
+ "Preset 18": {
139
+ "camera": "Sigma fp L",
140
+ "lens": "Sigma 35mm f/1.4 DG DN Art",
141
+ "film": "Sigma 35mm f/1.4 DG DN Art",
142
+ "light": "Moonlight",
143
+ "scene": "Scene description for Sigma fp L",
144
+ "version": "7"
145
+ },
146
+ "Preset 19": {
147
+ "camera": "GoPro Hero 12 Black",
148
+ "lens": "GoPro Standard Lens",
149
+ "film": "GoPro Standard Lens",
150
+ "light": "Streetlight Glow",
151
+ "scene": "Scene description for GoPro Hero 12 Black",
152
+ "version": "7"
153
+ },
154
+ "Preset 20": {
155
+ "camera": "Blackmagic Pocket Cinema Camera 6K Pro",
156
+ "lens": "Sigma 18-35mm f/1.8 Art",
157
+ "film": "Sigma 18-35mm f/1.8 Art",
158
+ "light": "Reflected Light",
159
+ "scene": "Scene description for Blackmagic Pocket Cinema Camera 6K Pro",
160
  "version": "7"
161
  }
162
  }