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