Judge_system / app.py
Lashtw's picture
Update app.py
5749276 verified
raw
history blame
7.55 kB
import gradio as gr
# Replace the CSV data loading with in-memory data
data = [
{"่››็ตฒ้ฆฌ่ทก": 1, "ๅซŒ็–‘็Šฏ": "5ๅ†ฐๆท‡ๆท‹ๅธซๅ‚…", "็›ดๆŽฅ่ญ‰ๆ“š": "SAS", "้–“ๆŽฅ่ญ‰ๆ“š": "RHS SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/5JLMDX.png"},
{"่››็ตฒ้ฆฌ่ทก": 2, "ๅซŒ็–‘็Šฏ": "7ๅ€™้ธไบบ", "็›ดๆŽฅ่ญ‰ๆ“š": "SSS", "้–“ๆŽฅ่ญ‰ๆ“š": "SAS ASA AAS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/WmOolp.png"},
{"่››็ตฒ้ฆฌ่ทก": 3, "ๅซŒ็–‘็Šฏ": "8ๅˆ—่ปŠ้•ท", "็›ดๆŽฅ่ญ‰ๆ“š": "SAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/Fk6fHM.png"},
{"่››็ตฒ้ฆฌ่ทก": 4, "ๅซŒ็–‘็Šฏ": "2่พฒๅคซ", "็›ดๆŽฅ่ญ‰ๆ“š": "SSS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/9z0FQ1.png"},
{"่››็ตฒ้ฆฌ่ทก": 5, "ๅซŒ็–‘็Šฏ": "1ๆผๅคซ", "็›ดๆŽฅ่ญ‰ๆ“š": "RHS", "้–“ๆŽฅ่ญ‰ๆ“š": "SAS SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/91iAHn.png"},
{"่››็ตฒ้ฆฌ่ทก": 6, "ๅซŒ็–‘็Šฏ": "4ๅปšๅธซ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/pSbKqG.png"},
{"่››็ตฒ้ฆฌ่ทก": 7, "ๅซŒ็–‘็Šฏ": "3ๅฅณๅƒ•", "็›ดๆŽฅ่ญ‰ๆ“š": "RHS", "้–“ๆŽฅ่ญ‰ๆ“š": "SAS SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/XGoFYq.png"},
{"่››็ตฒ้ฆฌ่ทก": 8, "ๅซŒ็–‘็Šฏ": "6ๆฃ‹ๅฃซ", "็›ดๆŽฅ่ญ‰ๆ“š": "AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "ASA", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/dMZ4I8.png"},
{"่››็ตฒ้ฆฌ่ทก": 9, "ๅซŒ็–‘็Šฏ": "10่Šญ่•พ่ˆž่€…", "็›ดๆŽฅ่ญ‰ๆ“š": "SSS", "้–“ๆŽฅ่ญ‰ๆ“š": "SAS AAS ASA", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/nFohKW.png"},
{"่››็ตฒ้ฆฌ่ทก": 10, "ๅซŒ็–‘็Šฏ": "9 DJ", "็›ดๆŽฅ่ญ‰ๆ“š": "SAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/5fwCDV.png"},
{"่››็ตฒ้ฆฌ่ทก": 11, "ๅซŒ็–‘็Šฏ": "16้€ ๅž‹ๅธซ", "็›ดๆŽฅ่ญ‰ๆ“š": "RHS", "้–“ๆŽฅ่ญ‰ๆ“š": "SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/zd4iXu.png"},
{"่››็ตฒ้ฆฌ่ทก": 12, "ๅซŒ็–‘็Šฏ": "12ๆ•™ๅฎ—", "็›ดๆŽฅ่ญ‰ๆ“š": "SSS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/3q4ICp.png"},
{"่››็ตฒ้ฆฌ่ทก": 13, "ๅซŒ็–‘็Šฏ": "14้Ÿณๆจ‚ๅฎถ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/CIKmMs.png"},
{"่››็ตฒ้ฆฌ่ทก": 14, "ๅซŒ็–‘็Šฏ": "13่ปไบบ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/BfGyn5.png"},
{"่››็ตฒ้ฆฌ่ทก": 15, "ๅซŒ็–‘็Šฏ": "17ๅ’Œๅฐš", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/prwQVq.png"},
{"่››็ตฒ้ฆฌ่ทก": 16, "ๅซŒ็–‘็Šฏ": "18ๆญŒๆ‰‹", "็›ดๆŽฅ่ญ‰ๆ“š": "AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "ASA", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/mtBa2p.png"},
{"่››็ตฒ้ฆฌ่ทก": 17, "ๅซŒ็–‘็Šฏ": "11้†ซ็”Ÿ", "็›ดๆŽฅ่ญ‰ๆ“š": "SAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/T8kgnq.png"},
{"่››็ตฒ้ฆฌ่ทก": 18, "ๅซŒ็–‘็Šฏ": "15ๅฃฝๅธๅธซๅ‚…", "็›ดๆŽฅ่ญ‰ๆ“š": "SAS", "้–“ๆŽฅ่ญ‰ๆ“š": "AAS ASA SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/fWMhki.png"},
{"่››็ตฒ้ฆฌ่ทก": 19, "ๅซŒ็–‘็Šฏ": "21้ƒตๅทฎ", "็›ดๆŽฅ่ญ‰ๆ“š": "RHS", "้–“ๆŽฅ่ญ‰ๆ“š": "SAS SSS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/kUuriv.png"},
{"่››็ตฒ้ฆฌ่ทก": 20, "ๅซŒ็–‘็Šฏ": "19็ฑƒ็ƒๅ“ก", "็›ดๆŽฅ่ญ‰ๆ“š": "RHS", "้–“ๆŽฅ่ญ‰ๆ“š": "SSS SAS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/uhman9.png"},
{"่››็ตฒ้ฆฌ่ทก": 21, "ๅซŒ็–‘็Šฏ": "22ๆณ•ๅฎ˜", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/R1ZipX.png"},
{"่››็ตฒ้ฆฌ่ทก": 22, "ๅซŒ็–‘็Šฏ": "20ๆผซ็•ซๅฎถ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/yaZhP7.png"},
{"่››็ตฒ้ฆฌ่ทก": 23, "ๅซŒ็–‘็Šฏ": "25ๆฎบๆ‰‹", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/5dVfQW.png"},
{"่››็ตฒ้ฆฌ่ทก": 24, "ๅซŒ็–‘็Šฏ": "28็ง‘ๅญธๅฎถ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "็„ก", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/Vj8MfX.png"},
{"่››็ตฒ้ฆฌ่ทก": 25, "ๅซŒ็–‘็Šฏ": "27ๅคช็ฉบไบบ", "็›ดๆŽฅ่ญ‰ๆ“š": "SSS", "้–“ๆŽฅ่ญ‰ๆ“š": "ASA AAS RHS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/hdso0N.png"},
{"่››็ตฒ้ฆฌ่ทก": 26, "ๅซŒ็–‘็Šฏ": "23้…’ไฟ", "็›ดๆŽฅ่ญ‰ๆ“š": "AAS", "้–“ๆŽฅ่ญ‰ๆ“š": "ASA", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/UFJMlD.png"},
{"่››็ตฒ้ฆฌ่ทก": 27, "ๅซŒ็–‘็Šฏ": "24้ญ”่ก“ๅธซ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA", "้–“ๆŽฅ่ญ‰ๆ“š": "AAS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/jEAikS.png"},
{"่››็ตฒ้ฆฌ่ทก": 28, "ๅซŒ็–‘็Šฏ": "26ไฟๅ…จ", "็›ดๆŽฅ่ญ‰ๆ“š": "ASA", "้–“ๆŽฅ่ญ‰ๆ“š": "AAS", "ๅซŒ็–‘็Šฏๅœ–็‰‡": "https://upload.cc/i1/2024/12/24/zh7qco.png"}
]
# To store the indirect evidence dynamically
indirect_evidence_store = ""
def query_data(clue_number):
global indirect_evidence_store
try:
clue_number = int(clue_number)
row = next((item for item in data if item['่››็ตฒ้ฆฌ่ทก'] == clue_number), None)
if row:
suspect = row['ๅซŒ็–‘็Šฏ']
direct_evidence = row['็›ดๆŽฅ่ญ‰ๆ“š']
indirect_evidence_store = row['้–“ๆŽฅ่ญ‰ๆ“š'] if row['้–“ๆŽฅ่ญ‰ๆ“š'] else "็„ก้–“ๆŽฅ่ญ‰ๆ“š"
image_url = row['ๅซŒ็–‘็Šฏๅœ–็‰‡'] if row['ๅซŒ็–‘็Šฏๅœ–็‰‡'] else None
return (
f"ๅซŒ็–‘็Šฏ: {suspect}\n็›ดๆŽฅ่ญ‰ๆ“š: {direct_evidence}",
gr.update(visible=True),
gr.update(value="", visible=False),
image_url if image_url else None
)
else:
return (
"ๆœชๆ‰พๅˆฐ็›ธ้—œ่ณ‡ๆ–™๏ผŒ่ซ‹ๆชขๆŸฅ่››็ตฒ้ฆฌ่ทก่™Ÿ็ขผๆ˜ฏๅฆๆญฃ็ขบใ€‚",
gr.update(visible=False),
gr.update(value="", visible=False),
None
)
except ValueError:
return (
"่ซ‹่ผธๅ…ฅๆœ‰ๆ•ˆ็š„ๆ•ธๅญ—ใ€‚",
gr.update(visible=False),
gr.update(value="", visible=False),
None
)
def show_indirect_evidence():
global indirect_evidence_store
return gr.update(value=indirect_evidence_store, visible=True)
def reset_fields():
global indirect_evidence_store
indirect_evidence_store = ""
return (
"",
gr.update(visible=False),
gr.update(value="", visible=False),
gr.update(value="", visible=True),
None
)
# Create the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("<h1>ๅซŒ็–‘็ŠฏABC็š„็พ่บซ</h1>")
gr.Markdown("<h3>ๆณ•ๅฎ˜็ณป็ตฑ</h3>")
with gr.Row():
input_box = gr.Textbox(label="่ซ‹่ผธๅ…ฅ่››็ตฒ้ฆฌ่ทก่™Ÿ็ขผ", placeholder="ไพ‹ๅฆ‚: 11", lines=1)
query_button = gr.Button("ๆŸฅ่ฉข")
output_box = gr.Textbox(label="ๆŸฅ่ฉข็ตๆžœ", interactive=False)
image_output = gr.Image(label="ๅซŒ็–‘็Šฏๅœ–็‰‡", visible=True)
indirect_button = gr.Button("้–“ๆŽฅ่ญ‰ๆ“š", visible=False)
indirect_output = gr.Textbox(label="้–“ๆŽฅ่ญ‰ๆ“šๅ…งๅฎน", interactive=False, visible=False)
reset_button = gr.Button("้‡ๆ–ฐๆŸฅ่ฉข")
# Bind actions to functions
query_button.click(
query_data,
inputs=input_box,
outputs=[output_box, indirect_button, indirect_output, image_output]
)
indirect_button.click(
show_indirect_evidence,
inputs=None,
outputs=indirect_output
)
reset_button.click(
reset_fields,
inputs=None,
outputs=[input_box, indirect_button, indirect_output, output_box, image_output]
)
# Launch the Gradio app
demo.launch()