TischEins commited on
Commit
f862749
·
verified ·
1 Parent(s): 4f44ccb

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +69 -0
  2. presets.json +5 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
69
+ demo.launch()
presets.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
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
+ }
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ pandas