Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# ์ด ํจ์๋ ์ฌ์ฉ์ ์
๋ ฅ์ ๋ํ ๋๋ ์ด์
์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํฉ๋๋ค.
|
4 |
+
# ์ค์ ์ ํ๋ฆฌ์ผ์ด์
์์๋ OpenAI API๋ ๋ค๋ฅธ ๋ชจ๋ธ์ ์ฌ์ฉํด ๊ตฌํํ ์ ์์ต๋๋ค.
|
5 |
+
def generate_script(inputs):
|
6 |
+
# ์์๋ฅผ ์ํ ๊ฐ์์ ์คํฌ๋ฆฝํธ ๋ฐํ
|
7 |
+
return "์ด๊ณณ์ ํ๋ คํ ๋์์ ์ ๊ฒฝ์
๋๋ค.\n์ ๋ฉ๋ฆฌ ๋น๋๋ ๋น๋ฉ๋ค ์ฌ์ด๋ก ํ ๋ฆฌ๊ฐ ๋ ์๊ฐ๋๋ค."
|
8 |
+
|
9 |
+
# Gradio ์ธํฐํ์ด์ค๋ฅผ ๋ก๋ํ๋ ํจ์
|
10 |
+
def load_interface():
|
11 |
+
return gr.Interface.load("models/goofyai/3d_render_style_xl")
|
12 |
+
|
13 |
+
# ์คํฌ๋ฆฝํธ์ ๊ฐ ์ค์ ์ด๋ฏธ์ง๋ก ๋ณํํ๋ ํจ์
|
14 |
+
def script_to_images(script):
|
15 |
+
# ๋ฏธ๋ฆฌ ๋ก๋ํ Gradio ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉ
|
16 |
+
iface = load_interface()
|
17 |
+
images = []
|
18 |
+
for line in script.split('\n'):
|
19 |
+
# ์ด๋ฏธ์ง ์์ฑ ๋ชจ๋ธ์ ๊ฐ ์คํฌ๋ฆฝํธ ์ค์ ์
๋ ฅ์ผ๋ก ์ ๊ณต
|
20 |
+
image = iface(line)
|
21 |
+
images.append(image)
|
22 |
+
return images
|
23 |
+
|
24 |
+
with gr.Blocks() as demo:
|
25 |
+
with gr.Row():
|
26 |
+
inputs = gr.Textbox(label="๋๋ ์ด์
์คํฌ๋ฆฝํธ ์
๋ ฅ")
|
27 |
+
generate_btn = gr.Button("๋๋ ์ด์
์คํฌ๋ฆฝํธ ์์ฑ")
|
28 |
+
with gr.Row():
|
29 |
+
script_output = gr.Textbox(label="์์ฑ๋ ์คํฌ๋ฆฝํธ", interactive=False)
|
30 |
+
with gr.Row():
|
31 |
+
images_output = gr.Gallery(label="์์ฑ๋ ์ด๋ฏธ์ง")
|
32 |
+
|
33 |
+
# ์คํฌ๋ฆฝํธ ์์ฑ ๋ฒํผ ํด๋ฆญ ์ ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
34 |
+
generate_btn.click(fn=generate_script, inputs=inputs, outputs=script_output)
|
35 |
+
|
36 |
+
# ์คํฌ๋ฆฝํธ ์ถ๋ ฅ๊ฐ ๋ณ๊ฒฝ ์ ์ด๋ฏธ์ง ์์ฑ ํจ์ ํธ์ถ
|
37 |
+
script_output.change(fn=script_to_images, inputs=script_output, outputs=images_output)
|
38 |
+
|
39 |
+
demo.launch()
|