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

Upload 3 files

Browse files
Files changed (2) hide show
  1. app.py +97 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1 +1,97 @@
1
- # Placeholder
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import pandas as pd
4
+ import random
5
+ import json
6
+
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()
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- # Placeholder
 
 
1
+ gradio
2
+ pandas