Spaces:
Sleeping
Sleeping
updated flow
Browse files- gradio_app.py +36 -0
- main.py +3 -11
gradio_app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from main import flow
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
with gr.Blocks(theme= "JohnSmith9982/small_and_pretty") as demo:
|
| 6 |
+
|
| 7 |
+
gr.HTML(
|
| 8 |
+
"""
|
| 9 |
+
<h1 style="font-size: 3.5em; text-align: center; color: #02c160; font-weight: bold;">AI Exam Checker</h1>
|
| 10 |
+
"""
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
with gr.Row():
|
| 14 |
+
with gr.Column():
|
| 15 |
+
student_pdf_path = gr.File(label="Student's PDF Response")
|
| 16 |
+
with gr.Column():
|
| 17 |
+
standard_pdf_path = gr.File(label="Standard Answer Key PDF")
|
| 18 |
+
|
| 19 |
+
with gr.Row():
|
| 20 |
+
submit_btn = gr.Button("Evaluate Exam")
|
| 21 |
+
|
| 22 |
+
with gr.Row():
|
| 23 |
+
output = gr.File(label="Output PDF", interactive=False)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def evaluate_exam(student_pdf_path, standard_pdf_path):
|
| 27 |
+
|
| 28 |
+
save_dict = True
|
| 29 |
+
student_dict_path = "student_response.json"
|
| 30 |
+
standard_dict_path = "standard_key.json"
|
| 31 |
+
output_pdf_path = "output_report.pdf"
|
| 32 |
+
|
| 33 |
+
return flow(student_pdf_path, standard_pdf_path, save_dict, student_dict_path, standard_dict_path, output_pdf_path)
|
| 34 |
+
|
| 35 |
+
submit_btn.click(evaluate_exam, inputs=[student_pdf_path, standard_pdf_path], outputs=output)
|
| 36 |
+
demo.launch(share=True, pwa=True, debug=True)
|
main.py
CHANGED
|
@@ -15,26 +15,18 @@ def flow(student_pdf_path: str,
|
|
| 15 |
|
| 16 |
# create new interim_files folder if multiple instances of the flow are run
|
| 17 |
|
| 18 |
-
# Transcribe the student's PDF response
|
| 19 |
-
print("Transcribing the student's response")
|
| 20 |
-
student_resp = transcribe_pdf(student_pdf_path, "interim_files_student", save_dict, student_dict_path)
|
| 21 |
-
print("--------------------------------------------")
|
| 22 |
# Transcribe the student's PDF response
|
| 23 |
print("Transcribing the student's response")
|
| 24 |
student_resp = transcribe_pdf(student_pdf_path, "interim_files_student", save_dict, student_dict_path)
|
| 25 |
print("--------------------------------------------")
|
| 26 |
|
| 27 |
-
# Transcribe the standard answer key PDF
|
| 28 |
-
print("Transcribing the standard answer key")
|
| 29 |
-
standard_key = transcribe_pdf(standard_pdf_path, "interim_files_standard", save_dict, standard_dict_path)
|
| 30 |
-
print("--------------------------------------------")
|
| 31 |
# Transcribe the standard answer key PDF
|
| 32 |
print("Transcribing the standard answer key")
|
| 33 |
standard_key = transcribe_pdf(standard_pdf_path, "interim_files_standard", save_dict, standard_dict_path)
|
| 34 |
print("--------------------------------------------")
|
| 35 |
|
| 36 |
-
# comment if running full flow
|
| 37 |
-
# when testing the evaluator only
|
| 38 |
# student_resp = json.load(open(student_dict_path, "r"))
|
| 39 |
# standard_key = json.load(open(standard_dict_path, "r"))
|
| 40 |
|
|
@@ -67,7 +59,7 @@ if __name__ == "__main__":
|
|
| 67 |
|
| 68 |
student_pdf_path = "examples/ca inter chapter - amalgamation student answer.pdf"
|
| 69 |
standard_pdf_path = "examples/ca inter chapter - amalgamation.pdf"
|
| 70 |
-
|
| 71 |
save_dict = True
|
| 72 |
student_dict_path = "student_response.json"
|
| 73 |
standard_dict_path = "standard_key.json"
|
|
|
|
| 15 |
|
| 16 |
# create new interim_files folder if multiple instances of the flow are run
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Transcribe the student's PDF response
|
| 19 |
print("Transcribing the student's response")
|
| 20 |
student_resp = transcribe_pdf(student_pdf_path, "interim_files_student", save_dict, student_dict_path)
|
| 21 |
print("--------------------------------------------")
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# Transcribe the standard answer key PDF
|
| 24 |
print("Transcribing the standard answer key")
|
| 25 |
standard_key = transcribe_pdf(standard_pdf_path, "interim_files_standard", save_dict, standard_dict_path)
|
| 26 |
print("--------------------------------------------")
|
| 27 |
|
| 28 |
+
# # comment if running full flow
|
| 29 |
+
# # when testing the evaluator only
|
| 30 |
# student_resp = json.load(open(student_dict_path, "r"))
|
| 31 |
# standard_key = json.load(open(standard_dict_path, "r"))
|
| 32 |
|
|
|
|
| 59 |
|
| 60 |
student_pdf_path = "examples/ca inter chapter - amalgamation student answer.pdf"
|
| 61 |
standard_pdf_path = "examples/ca inter chapter - amalgamation.pdf"
|
| 62 |
+
|
| 63 |
save_dict = True
|
| 64 |
student_dict_path = "student_response.json"
|
| 65 |
standard_dict_path = "standard_key.json"
|