Spaces:
Runtime error
Runtime error
import gradio as gr | |
from huggingface_hub import InferenceClient | |
import pandas as pd | |
df = pd.read_csv("Diemthi2024_processed.csv") | |
def respond( | |
sbd, khoi | |
): | |
khoi = khoi.lower() | |
score = df[df['sbd'] == int(sbd)] | |
count_all = (df[khoi] >= score[khoi].iloc[0]).sum() | |
count_kv = ((df[khoi] >= score[khoi].iloc[0]) & (df['kv'] == score['kv'].iloc[0])).sum() | |
count_tinh = ((df[khoi] >= score[khoi].iloc[0]) & (df['tinh'] == score['tinh'].iloc[0])).sum() | |
return f"""Your score is {score[khoi].iloc[0]} | |
National Ranking: {count_all} | |
Regional Ranking: {count_kv} | |
Provincal Ranking: {count_tinh}""" | |
""" | |
Chatbot | |
""" | |
with gr.Blocks() as demo: | |
gr.Markdown( | |
""" | |
<style> | |
.gr-button-secondary { | |
width: 100px; | |
height: 30px; | |
padding: 5px; | |
} | |
.gr-row { | |
display: flex; | |
align-items: center; | |
gap: 10px; | |
} | |
.gr-block { | |
padding: 20px; | |
} | |
.gr-markdown p { | |
font-size: 16px; | |
} | |
</style> | |
<span style='font-family: Arial, sans-serif; font-size: 20px;'>National Graduation Exam Score Ranking</span> | |
<p style='font-family: Arial, sans-serif;'>Input your ID and your combination:</p> | |
""" | |
) | |
with gr.Row(): | |
id = gr.Textbox(placeholder="Input your ID", label="", lines=1) | |
comb = gr.Dropdown( | |
["A00", "A01", "B00", "C00", "C03", "D01", "D07"], label="Combination", info="Will add more combinations later!" | |
) | |
with gr.Row(): | |
check_button = gr.Button("Rank now!", variant="primary") | |
out = gr.Textbox(label="OUTPUT", placeholder="", lines=2) | |
check_button.click(fn=respond, inputs=[id,comb], outputs=out) | |
if __name__ == "__main__": | |
demo.launch() |