openfree commited on
Commit
c360d3b
ยท
verified ยท
1 Parent(s): 0f3a598

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +43 -0
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()