Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -1,209 +1,95 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
-
import random
|
| 4 |
import pandas as pd
|
| 5 |
-
import
|
| 6 |
|
|
|
|
| 7 |
camera_lens_map = {
|
| 8 |
-
|
| 9 |
-
"
|
| 10 |
-
|
| 11 |
-
"Canon RF 85mm f/1.2L USM"
|
| 12 |
-
],
|
| 13 |
-
"Sony Alpha 7R V": [
|
| 14 |
-
"Sony FE 85mm f/1.4 GM",
|
| 15 |
-
"Sony FE 24-70mm f/2.8 GM II",
|
| 16 |
-
"Sony FE 50mm f/1.2 GM"
|
| 17 |
-
],
|
| 18 |
-
"Fujifilm GFX 100 II": [
|
| 19 |
-
"Fujifilm GF 80mm f/1.7 R WR",
|
| 20 |
-
"Fujifilm GF 45mm f/2.8 R WR",
|
| 21 |
-
"Fujifilm GF 110mm f/2 R LM WR"
|
| 22 |
-
],
|
| 23 |
-
"Leica M11": [
|
| 24 |
-
"Leica Summilux-M 50mm f/1.4 ASPH",
|
| 25 |
-
"Leica APO-Summicron-M 75mm f/2 ASPH",
|
| 26 |
-
"Leica Elmarit-M 28mm f/2.8 ASPH"
|
| 27 |
-
]
|
| 28 |
}
|
| 29 |
camera_film_map = {
|
| 30 |
-
|
| 31 |
-
"Kodak
|
| 32 |
-
|
| 33 |
-
"Kodak Gold 200"
|
| 34 |
-
],
|
| 35 |
-
"Sony Alpha 7R V": [
|
| 36 |
-
"Agfa Vista 200",
|
| 37 |
-
"Kodak Ultramax 400",
|
| 38 |
-
"Fujifilm C200"
|
| 39 |
-
],
|
| 40 |
-
"Fujifilm GFX 100 II": [
|
| 41 |
-
"Fujifilm Pro 400H",
|
| 42 |
-
"Fujifilm Provia 100F",
|
| 43 |
-
"Fujifilm Velvia 50"
|
| 44 |
-
],
|
| 45 |
-
"Leica M11": [
|
| 46 |
-
"Ilford HP5 Plus",
|
| 47 |
-
"Kodak T-Max 100",
|
| 48 |
-
"AgfaPhoto APX 100"
|
| 49 |
-
]
|
| 50 |
}
|
| 51 |
light_conditions = [
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
"Twilight Glow",
|
| 58 |
-
"Morning Fog",
|
| 59 |
-
"Studio Lighting",
|
| 60 |
-
"Soft Ambient Light",
|
| 61 |
-
"Window Light",
|
| 62 |
-
"Dappled Light",
|
| 63 |
-
"Hard Shadow",
|
| 64 |
-
"Spotlight",
|
| 65 |
-
"Stage Lighting",
|
| 66 |
-
"Silhouette Light",
|
| 67 |
-
"Fluorescent Light",
|
| 68 |
-
"Candlelight",
|
| 69 |
-
"Moonlight",
|
| 70 |
-
"Streetlight Glow",
|
| 71 |
-
"Reflected Light"
|
| 72 |
]
|
| 73 |
-
mj_versions = ["6",
|
| 74 |
-
presets = {
|
| 75 |
-
"Sunset Portrait": {
|
| 76 |
-
"camera": "Canon EOS R5",
|
| 77 |
-
"lens": "Canon RF 50mm f/1.2L USM",
|
| 78 |
-
"film": "Kodak Portra 400",
|
| 79 |
-
"light": "Golden Hour",
|
| 80 |
-
"scene": "A woman standing in a field of tall grass during sunset, soft wind in her hair",
|
| 81 |
-
"version": "7"
|
| 82 |
-
},
|
| 83 |
-
"Urban Streetstyle": {
|
| 84 |
-
"camera": "Sony Alpha 7R V",
|
| 85 |
-
"lens": "Sony FE 85mm f/1.4 GM",
|
| 86 |
-
"film": "Kodak Ultramax 400",
|
| 87 |
-
"light": "Backlighting",
|
| 88 |
-
"scene": "Young man walking through a neon-lit city street at night with glowing billboards",
|
| 89 |
-
"version": "6.1"
|
| 90 |
-
},
|
| 91 |
-
"Forest Fantasy": {
|
| 92 |
-
"camera": "Fujifilm GFX 100 II",
|
| 93 |
-
"lens": "Fujifilm GF 80mm f/1.7 R WR",
|
| 94 |
-
"film": "Fujifilm Provia 100F",
|
| 95 |
-
"light": "Diffused Light",
|
| 96 |
-
"scene": "A mysterious elf walking through a foggy forest with glowing mushrooms",
|
| 97 |
-
"version": "6"
|
| 98 |
-
},
|
| 99 |
-
"Classic Black and White": {
|
| 100 |
-
"camera": "Leica M11",
|
| 101 |
-
"lens": "Leica Summilux-M 50mm f/1.4 ASPH",
|
| 102 |
-
"film": "Ilford HP5 Plus",
|
| 103 |
-
"light": "Soft Ambient Light",
|
| 104 |
-
"scene": "Man reading newspaper in a Parisian caf\u00e9, 1950s",
|
| 105 |
-
"version": "7"
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
scene_variations = [
|
| 109 |
-
"with dramatic lens flare",
|
| 110 |
-
"with soft bokeh background",
|
| 111 |
-
"with rich cinematic contrast",
|
| 112 |
-
"with muted pastel tones",
|
| 113 |
-
"with vibrant color pop",
|
| 114 |
-
"with deep shadows",
|
| 115 |
-
"with high-key brightness",
|
| 116 |
-
"with low-key mood",
|
| 117 |
-
"with subtle grain texture",
|
| 118 |
-
"with glossy reflections",
|
| 119 |
-
"with backlit rim light",
|
| 120 |
-
"with fine detail sharpness",
|
| 121 |
-
"with wide-angle perspective",
|
| 122 |
-
"with telephoto compression",
|
| 123 |
-
"with macro-level close-up",
|
| 124 |
-
"with panoramic scope",
|
| 125 |
-
"with dreamy glow",
|
| 126 |
-
"with crisp clarity",
|
| 127 |
-
"with vintage film grain",
|
| 128 |
-
"with modern hyperrealism"
|
| 129 |
-
]
|
| 130 |
-
|
| 131 |
-
def update_lens(camera):
|
| 132 |
-
return gr.update(choices=camera_lens_map[camera], value=camera_lens_map[camera][0])
|
| 133 |
|
| 134 |
-
def
|
| 135 |
-
|
| 136 |
|
| 137 |
-
def
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
camera_lens_map[pre["camera"]][0],
|
| 142 |
-
camera_film_map[pre["camera"]][0],
|
| 143 |
-
pre["light"],
|
| 144 |
-
pre["scene"],
|
| 145 |
-
pre["version"]
|
| 146 |
-
)
|
| 147 |
-
|
| 148 |
-
def generate_prompts(engine, mj_version, camera, lens, film, light, aspect_ratio, quality, stylize, seed, base_scene, num):
|
| 149 |
-
prompts = []
|
| 150 |
-
# choose variations
|
| 151 |
-
vars = random.sample(scene_variations, min(num, len(scene_variations)))
|
| 152 |
-
for i in range(num):
|
| 153 |
-
scene = f"{base_scene}, {vars[i]}"
|
| 154 |
-
mj_args = f"--ar {aspect_ratio} --q {quality} --s {stylize}"
|
| 155 |
-
if seed: mj_args += f" --seed {seed}"
|
| 156 |
-
if engine == "Midjourney":
|
| 157 |
-
prompt = f"{scene}, shot with {camera} and {lens}, using {film} film, under {light} {mj_args} --v {mj_version}"
|
| 158 |
-
else:
|
| 159 |
-
prompt = f"A detailed scene of {scene}, captured using a {camera} and {lens}, simulated with {film} film look and {light} lighting."
|
| 160 |
prompts.append(prompt)
|
| 161 |
return "\n".join(prompts), prompts
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
def export_txt(prompts):
|
| 164 |
-
with open("prompts.txt","w") as f:
|
| 165 |
-
|
| 166 |
-
return gr.File.update(value="prompts.txt", visible=True)
|
| 167 |
|
| 168 |
def export_csv(prompts):
|
| 169 |
-
df
|
| 170 |
-
df.to_csv("prompts.csv",
|
| 171 |
-
return gr.File.update(value="prompts.csv"
|
| 172 |
|
| 173 |
with gr.Blocks() as demo:
|
| 174 |
-
gr.Markdown("
|
| 175 |
-
|
| 176 |
-
psel = gr.Dropdown(choices=list(presets.keys()), label="Select Preset")
|
| 177 |
-
eng = gr.Radio(["Midjourney","ChatGPT Sora"], label="Engine", value="Midjourney")
|
| 178 |
-
mjv = gr.Dropdown(choices=mj_versions, label="MJ Version", value="7", visible=True)
|
| 179 |
-
cam = gr.Dropdown(choices=list(camera_lens_map.keys()), label="Camera Model")
|
| 180 |
-
len_ = gr.Dropdown(choices=[], label="Lens Model")
|
| 181 |
-
film = gr.Dropdown(choices=[], label="Color Film Type")
|
| 182 |
-
light = gr.Dropdown(choices=light_conditions, label="Light Condition")
|
| 183 |
-
ar = gr.Textbox(label="Aspect Ratio", value="5:4", visible=True)
|
| 184 |
-
q = gr.Textbox(label="Quality", value="2", visible=True)
|
| 185 |
-
s = gr.Textbox(label="Stylize", value="0", visible=True)
|
| 186 |
-
seed = gr.Textbox(label="Seed", placeholder="optional")
|
| 187 |
-
base_scene = gr.Textbox(label="Scene Description")
|
| 188 |
-
num = gr.Slider(1,50,value=3,label="Number of Prompts")
|
| 189 |
-
out = gr.Textbox(label="Prompts", lines=20)
|
| 190 |
-
state = gr.State([])
|
| 191 |
-
|
| 192 |
-
psel.change(fn=apply_preset, inputs=psel, outputs=[cam,len_,film,light,base_scene,mjv])
|
| 193 |
-
cam.change(fn=update_lens, inputs=cam, outputs=len_)
|
| 194 |
-
cam.change(fn=update_film, inputs=cam, outputs=film)
|
| 195 |
-
eng.change(lambda e: [gr.update(visible=e=="Midjourney")]*3, inputs=eng, outputs=[mjv,ar,q,s])
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
-
gr.Markdown('<a href="https://tischeins.org">Pro Studio
|
| 208 |
|
| 209 |
demo.launch()
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
+
import random
|
| 5 |
|
| 6 |
+
# Sample mappings (should include all 20 entries)
|
| 7 |
camera_lens_map = {
|
| 8 |
+
"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"],
|
| 9 |
+
"Nikon Z8": ["Nikon Z 50mm f/1.2 S", "Nikon Z 85mm f/1.8 S", "Nikon Z 24-70mm f/2.8 S"]
|
| 10 |
+
# ... add remaining cameras
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
camera_film_map = {
|
| 13 |
+
"Canon EOS R5": ["Kodak Portra 400", "Kodak Ektar 100", "Kodak Gold 200"],
|
| 14 |
+
"Nikon Z8": ["Cinestill 800T", "Kodak Tri-X 400", "Fujifilm Superia X-TRA 400"]
|
| 15 |
+
# ... add remaining cameras
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
light_conditions = [
|
| 18 |
+
# 20 conditions
|
| 19 |
+
"Golden Hour","Blue Hour","Backlighting","Overcast Light","High Noon Sunlight",
|
| 20 |
+
"Twilight Glow","Morning Fog","Studio Lighting","Soft Ambient Light","Window Light",
|
| 21 |
+
"Dappled Light","Hard Shadow","Spotlight","Stage Lighting","Silhouette Light",
|
| 22 |
+
"Fluorescent Light","Candlelight","Moonlight","Streetlight Glow","Reflected Light"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
]
|
| 24 |
+
mj_versions = ["6","6.1","7"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
def update_lens(camera): return gr.update(choices=camera_lens_map.get(camera, []))
|
| 27 |
+
def update_film(camera): return gr.update(choices=camera_film_map.get(camera, []))
|
| 28 |
|
| 29 |
+
def generate_midjourney(camera,lens,film,light,mj_version,aspect_ratio,quality,stylize,seed,scene,num):
|
| 30 |
+
prompts=[]
|
| 31 |
+
for _ in range(num):
|
| 32 |
+
prompt=f"{scene}, shot with {camera} and {lens}, using {film} film, under {light} --ar {aspect_ratio} --q {quality} --s {stylize}" + (f" --seed {seed}" if seed else "") + f" --v {mj_version}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
prompts.append(prompt)
|
| 34 |
return "\n".join(prompts), prompts
|
| 35 |
|
| 36 |
+
def generate_sora(camera,lens,film,light,scene,num):
|
| 37 |
+
prompts=[]
|
| 38 |
+
for _ in range(num):
|
| 39 |
+
prompts.append(f"A detailed scene of {scene}, captured using a {camera} and {lens}, simulated with {film} film look and {light} lighting.")
|
| 40 |
+
return "\n".join(prompts), prompts
|
| 41 |
+
|
| 42 |
def export_txt(prompts):
|
| 43 |
+
with open("prompts.txt","w") as f: f.write("\n".join(prompts))
|
| 44 |
+
return gr.File.update(value="prompts.txt")
|
|
|
|
| 45 |
|
| 46 |
def export_csv(prompts):
|
| 47 |
+
df=pd.DataFrame({"Prompt":prompts})
|
| 48 |
+
df.to_csv("prompts.csv",index=False)
|
| 49 |
+
return gr.File.update(value="prompts.csv")
|
| 50 |
|
| 51 |
with gr.Blocks() as demo:
|
| 52 |
+
gr.Markdown("## TischEins.org | Midjourney Prompt Engine\nPro Studio Prompt Generator for Midjourney and Sora")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
with gr.Tab("Midjourney"):
|
| 55 |
+
camera=gr.Dropdown(list(camera_lens_map.keys()),label="Camera Model")
|
| 56 |
+
lens=gr.Dropdown([],label="Lens Model")
|
| 57 |
+
film=gr.Dropdown([],label="Color Film Type")
|
| 58 |
+
light=gr.Dropdown(light_conditions,label="Light Condition")
|
| 59 |
+
mjv=gr.Dropdown(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 |
+
scene=gr.Textbox(label="Scene Description")
|
| 65 |
+
num=gr.Slider(1,50,5,label="Number of Prompts")
|
| 66 |
+
out_mid, state_mid = gr.Textbox(lines=10), gr.State([])
|
| 67 |
+
btn_mid=gr.Button("Generate")
|
| 68 |
+
btn_mid.click(generate_midjourney, inputs=[camera,lens,film,light,mjv,ar,q,s,seed,scene,num], outputs=[out_mid,state_mid])
|
| 69 |
+
txt_mid=gr.Button("Export TXT"); csv_mid=gr.Button("Export CSV")
|
| 70 |
+
dl_txt_mid=gr.File(visible=False); dl_csv_mid=gr.File(visible=False)
|
| 71 |
+
txt_mid.click(export_txt, inputs=state_mid, outputs=dl_txt_mid)
|
| 72 |
+
csv_mid.click(export_csv, inputs=state_mid, outputs=dl_csv_mid)
|
| 73 |
+
camera.change(update_lens, inputs=camera, outputs=lens)
|
| 74 |
+
camera.change(update_film, inputs=camera, outputs=film)
|
| 75 |
|
| 76 |
+
with gr.Tab("ChatGPT Sora"):
|
| 77 |
+
camera_s=gr.Dropdown(list(camera_lens_map.keys()),label="Camera Model")
|
| 78 |
+
lens_s=gr.Dropdown([],label="Lens Model")
|
| 79 |
+
film_s=gr.Dropdown([],label="Color Film Type")
|
| 80 |
+
light_s=gr.Dropdown(light_conditions,label="Light Condition")
|
| 81 |
+
scene_s=gr.Textbox(label="Scene Description")
|
| 82 |
+
num_s=gr.Slider(1,50,5,label="Number of Prompts")
|
| 83 |
+
out_s, state_s=gr.Textbox(lines=10), gr.State([])
|
| 84 |
+
btn_s=gr.Button("Generate")
|
| 85 |
+
btn_s.click(generate_sora, inputs=[camera_s,lens_s,film_s,light_s,scene_s,num_s], outputs=[out_s,state_s])
|
| 86 |
+
txt_s=gr.Button("Export TXT"); csv_s=gr.Button("Export CSV")
|
| 87 |
+
dl_txt_s=gr.File(visible=False); dl_csv_s=gr.File(visible=False)
|
| 88 |
+
txt_s.click(export_txt, inputs=state_s, outputs=dl_txt_s)
|
| 89 |
+
csv_s.click(export_csv, inputs=state_s, outputs=dl_csv_s)
|
| 90 |
+
camera_s.change(update_lens, inputs=camera_s, outputs=lens_s)
|
| 91 |
+
camera_s.change(update_film, inputs=camera_s, outputs=film_s)
|
| 92 |
|
| 93 |
+
gr.Markdown('<a href="https://tischeins.org">Pro Studio Mode by TischEins.org</a>')
|
| 94 |
|
| 95 |
demo.launch()
|