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

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +59 -43
  2. requirements.txt +0 -1
app.py CHANGED
@@ -1,68 +1,84 @@
1
 
2
  import gradio as gr
3
  import json
4
- import os
5
 
6
- PRESET_FILE = "presets.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- if not os.path.exists(PRESET_FILE):
9
- with open(PRESET_FILE, "w") as f:
10
- json.dump({}, f)
11
-
12
- def load_presets():
13
- with open(PRESET_FILE, "r") as f:
14
- return json.load(f)
15
-
16
- cameras = ['Canon EOS R5', 'Nikon Z8', 'Sony Alpha 7R V', 'Fujifilm GFX 100 II', 'Leica M11']
17
- lens_map = {'Canon EOS R5': ['Canon RF 50mm f/1.2L USM'], 'Nikon Z8': ['Nikon Z 50mm f/1.2 S'], 'Sony Alpha 7R V': ['Sony FE 85mm f/1.4 GM'], 'Fujifilm GFX 100 II': ['Fujifilm GF 80mm f/1.7 R WR'], 'Leica M11': ['Leica Summilux-M 50mm f/1.4 ASPH']}
18
- films = [
19
- "Kodak Portra 400", "Kodak Ektar 100", "Cinestill 800T", "Fujifilm Provia 100F", "Kodak Gold 200"
20
- ]
21
  light_conditions = [
22
  "Golden Hour", "Blue Hour", "Overcast Light", "Diffused Light", "Backlighting",
23
  "Soft Ambient Light", "Low-Key Lighting", "High-Key Lighting", "Window Light", "Dappled Light"
24
  ]
25
 
26
- def update_lens(camera):
27
- return gr.update(choices=lens_map.get(camera, []), value=lens_map.get(camera, [])[0])
28
 
29
- def generate_prompt(preset, custom_scene, camera, lens, film, light, aspect_ratio, quality, stylize, seed, num_prompts):
30
- presets = load_presets()
31
- scene_description = custom_scene if preset == "Custom Input" else presets.get(preset, "")
32
- mj_parameters = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
33
- if seed != "":
34
- mj_parameters += f" --seed {seed}"
 
 
35
  prompts = []
36
- for _ in range(num_prompts):
37
- prompt = f"{scene_description}, shot with {camera} and {lens}, using {film} film, under {light} {mj_parameters}"
 
 
 
38
  prompts.append(prompt)
39
  return "\n".join(prompts)
40
 
41
  with gr.Blocks() as demo:
42
  gr.Markdown("# TischEins.org | Midjourney Prompt Engine")
43
 
44
- with gr.Tab("Prompt Generator"):
45
- preset_choice = gr.Dropdown(choices=list(load_presets().keys()) + ["Custom Input"], label="Select Preset")
46
- custom_scene = gr.Textbox(label="Or enter your custom scene")
 
 
 
 
47
 
48
- camera_dropdown = gr.Dropdown(choices=cameras, label="Camera Model")
49
- lens_dropdown = gr.Dropdown(choices=[], label="Lens Model")
 
 
50
 
51
- film_dropdown = gr.Dropdown(choices=films, label="Color Film Type")
52
- light_dropdown = gr.Dropdown(choices=light_conditions, label="Light Condition")
53
- aspect_ratio = gr.Textbox(label="Aspect Ratio", value="5:4")
54
- quality = gr.Textbox(label="Quality", value="2")
55
- stylize = gr.Textbox(label="Stylize", value="750")
56
- seed = gr.Textbox(label="Seed (optional)", placeholder="Leave empty for random")
57
- num = gr.Slider(1, 100, 10, step=1, label="Number of Prompts")
58
 
59
- camera_dropdown.change(fn=update_lens, inputs=camera_dropdown, outputs=lens_dropdown)
 
60
 
61
- btn = gr.Button("Generate Prompts")
62
- output = gr.Textbox(label="Generated Prompts", lines=20)
63
- btn.click(fn=generate_prompt,
64
- inputs=[preset_choice, custom_scene, camera_dropdown, lens_dropdown, film_dropdown, light_dropdown, aspect_ratio, quality, stylize, seed, num],
65
- outputs=output)
 
66
 
67
  gr.Markdown('<a href="https://tischeins.org" target="_blank">Pro Studio Mode by TischEins.org</a>')
68
 
 
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}"
43
+ if seed:
44
+ mj_args += f" --seed {seed}"
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
 
54
  with gr.Blocks() as demo:
55
  gr.Markdown("# TischEins.org | Midjourney Prompt Engine")
56
 
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
 
65
+ aspect_ratio = gr.Textbox(label="Aspect Ratio", value="5:4", visible=True)
66
+ quality = gr.Textbox(label="Quality", value="2", visible=True)
67
+ stylize = gr.Textbox(label="Stylize", value="0", visible=True)
68
+ seed = gr.Textbox(label="Seed (optional)")
69
 
70
+ scene = gr.Textbox(label="Scene Description", placeholder="Describe your scene here...")
71
+ num = gr.Slider(1, 50, value=5, label="Number of Prompts")
 
 
 
 
 
72
 
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
 
83
  gr.Markdown('<a href="https://tischeins.org" target="_blank">Pro Studio Mode by TischEins.org</a>')
84
 
requirements.txt CHANGED
@@ -1,2 +1 @@
1
  gradio
2
- pandas
 
1
  gradio