seawolf2357 commited on
Commit
506d085
β€’
1 Parent(s): 6866c0d

Create app.py

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