Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -39,6 +39,26 @@ def predict(inputs, top_p, temperature, openai_api_key):
|
|
39 |
else:
|
40 |
return "Error: Unable to generate response."
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
with gr.Blocks() as demo:
|
43 |
gr.Markdown("<h1 align='center'>ν 리μ λͺ¨ν: 3D μ λλ©μ΄μ
μμ±κΈ°</h1>")
|
44 |
with gr.Row():
|
@@ -51,7 +71,10 @@ with gr.Blocks() as demo:
|
|
51 |
submit_button = gr.Button("Generate Script")
|
52 |
prompts_button = gr.Button("Generate Image Prompts")
|
53 |
|
|
|
|
|
|
|
54 |
submit_button.click(fn=predict, inputs=[inputs, top_p, temperature, openai_api_key], outputs=output)
|
55 |
-
prompts_button.click(fn=
|
56 |
|
57 |
-
demo.launch()
|
|
|
39 |
else:
|
40 |
return "Error: Unable to generate response."
|
41 |
|
42 |
+
def create_detailed_image_prompts(script):
|
43 |
+
# μ€ν¬λ¦½νΈμ κ° μ€μ λΆμνμ¬ ν둬ννΈ μμ±
|
44 |
+
lines = script.split('\n')
|
45 |
+
detailed_prompts = []
|
46 |
+
for line in lines:
|
47 |
+
# μ¬κΈ°μλ μμλ‘ λͺ κ°μ§ κ°λ¨ν ν¨ν΄μ μ¬μ©ν©λλ€.
|
48 |
+
# μ€μ ꡬνμμλ λ 볡μ‘ν μμ°μ΄ μ²λ¦¬λ₯Ό μ μ©ν΄μΌ ν μ μμ΅λλ€.
|
49 |
+
if "μΌκ΅¬μ₯μ κ°λ€" in line:
|
50 |
+
action = "go to the baseball (background)"
|
51 |
+
prompt = f"3d style, 4K, like Brad Pitt young boy, {action}"
|
52 |
+
elif "μ²μ νννλ€" in line:
|
53 |
+
action = "explore the forest (background)"
|
54 |
+
prompt = f"3d style, 4K, like Brad Pitt young boy, {action}"
|
55 |
+
else:
|
56 |
+
# μΌμΉνλ ν¨ν΄μ΄ μμ κ²½μ° κΈ°λ³Έ ν둬ννΈ μ¬μ©
|
57 |
+
prompt = f"3d style, 4K, like Brad Pitt young boy, adventure"
|
58 |
+
detailed_prompts.append(prompt)
|
59 |
+
return "\n".join(detailed_prompts)
|
60 |
+
|
61 |
+
# Gradio μΈν°νμ΄μ€ μμ
|
62 |
with gr.Blocks() as demo:
|
63 |
gr.Markdown("<h1 align='center'>ν 리μ λͺ¨ν: 3D μ λλ©μ΄μ
μμ±κΈ°</h1>")
|
64 |
with gr.Row():
|
|
|
71 |
submit_button = gr.Button("Generate Script")
|
72 |
prompts_button = gr.Button("Generate Image Prompts")
|
73 |
|
74 |
+
def generate_prompts(script):
|
75 |
+
return create_detailed_image_prompts(script)
|
76 |
+
|
77 |
submit_button.click(fn=predict, inputs=[inputs, top_p, temperature, openai_api_key], outputs=output)
|
78 |
+
prompts_button.click(fn=generate_prompts, inputs=[output], outputs=prompts_output)
|
79 |
|
80 |
+
demo.launch()
|