ergbpi / app.py
openfree's picture
Upload app.py with huggingface_hub
c360d3b verified
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()