Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
|
4 |
+
# μ§λ¬Έ λ° μ νμ§ μ€μ
|
5 |
+
questions = ["λΉμ μ μ’μνλ μμ 무μμ
λκΉ?", "μ΅κ³ μ μμμ 무μμ
λκΉ?"]
|
6 |
+
options = [["λΉ¨κ°", "νλ", "λ
Ήμ"], ["νΌμ", "μ€μ", "νμ€ν"]]
|
7 |
+
scores = [[10, 20, 30], [15, 25, 35]]
|
8 |
+
|
9 |
+
# μ¬μ©μμ μ νμ λ°λ₯Έ μ μ κ³μ°
|
10 |
+
def calculate_score(*choices):
|
11 |
+
total_score = sum(scores[i][options[i].index(choice)] for i, choice in enumerate(choices))
|
12 |
+
|
13 |
+
# μ°¨νΈ μμ±
|
14 |
+
plt.bar(["μ μ"], [total_score])
|
15 |
+
plt.ylim(0, 100)
|
16 |
+
return plt.gcf()
|
17 |
+
|
18 |
+
# Gradio μΈν°νμ΄μ€ μμ±
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=calculate_score,
|
21 |
+
inputs=[gr.Radio(labels=opts, label=ques) for ques, opts in zip(questions, options)],
|
22 |
+
outputs="plot"
|
23 |
+
)
|
24 |
+
|
25 |
+
# μ ν리μΌμ΄μ
μ€ν
|
26 |
+
iface.launch()
|