Upload app.py with huggingface_hub
Browse files
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
def generate_sentence(num_animals, animal_type, countries, location, activities, time_of_day):
|
4 |
+
country_str = ", ".join(countries)
|
5 |
+
activity_str = ", ".join(activities)
|
6 |
+
time = "์์นจ" if time_of_day else "์ ๋
"
|
7 |
+
sentence = f"{country_str}์์ ์จ {num_animals}๋ง๋ฆฌ์ {animal_type}์ด {location}์์ {activity_str} ํ์ต๋๋ค. {time}๊น์ง."
|
8 |
+
return sentence
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
with gr.Row():
|
11 |
+
with gr.Column():
|
12 |
+
num_slider = gr.Slider(minimum=2, maximum=20, step=1, label="๋๋ฌผ ์๋", value=2)
|
13 |
+
animal_dropdown = gr.Dropdown(
|
14 |
+
choices=["๊ฐ์์ง", "๊ณ ์์ด", "ํ ๋ผ", "ํ์คํฐ", "์ต๋ฌด์"],
|
15 |
+
label="๋๋ฌผ ์ข
๋ฅ",
|
16 |
+
value="๊ฐ์์ง"
|
17 |
+
)
|
18 |
+
countries = gr.CheckboxGroup(
|
19 |
+
choices=["ํ๊ตญ", "์ผ๋ณธ", "์ค๊ตญ", "๋ฏธ๊ตญ", "์๊ตญ"],
|
20 |
+
label="๊ตญ๊ฐ ์ ํ"
|
21 |
+
)
|
22 |
+
location = gr.Radio(
|
23 |
+
choices=["๊ณต์", "ํด๋ณ", "์ฐ", "๊ฐ๊ฐ", "์ฒ"],
|
24 |
+
label="์ฅ์",
|
25 |
+
value="๊ณต์"
|
26 |
+
)
|
27 |
+
activities = gr.Dropdown(
|
28 |
+
choices=["๋ฌ๋ฆฌ๊ธฐ", "์์", "์ ์๊ธฐ", "๋๊ธฐ", "๋จน๊ธฐ"],
|
29 |
+
label="ํ๋",
|
30 |
+
multiselect=True
|
31 |
+
)
|
32 |
+
time_checkbox = gr.Checkbox(label="์์นจ(์ฒดํฌ) / ์ ๋
(๋ฏธ์ฒดํฌ)")
|
33 |
+
with gr.Column():
|
34 |
+
output_text = gr.Textbox(label="์์ฑ๋ ๋ฌธ์ฅ")
|
35 |
+
generate_btn = gr.Button("๋ฌธ์ฅ ์์ฑํ๊ธฐ")
|
36 |
+
generate_btn.click(
|
37 |
+
fn=generate_sentence,
|
38 |
+
inputs=[num_slider, animal_dropdown, countries, location, activities, time_checkbox],
|
39 |
+
outputs=output_text
|
40 |
+
)
|
41 |
+
|
42 |
+
if __name__ == '__main__':
|
43 |
+
demo.launch()
|