a0ms1n's picture
Add 2 evaluates
ef679ef
raw
history blame
1.49 kB
import gradio as gr
import Evaluate1
import Evaluate2
import re
def load_cpp_file(file):
text = file.name
with open(text,'r',encoding='utf-8') as f:
content = f.read()
return content
with gr.Blocks() as web:
with gr.Row():
with gr.Column(scale=1):
code_box = gr.Textbox(lines=20, label="C++ Code")
with gr.Column(scale=1):
cpp_file = gr.File(label="Upload C++ File (.cpp)", file_types=[".cpp"])
check_btn = gr.Button("Check")
# Result section
with gr.Row():
gr.Markdown("### Result :")
with gr.Row():
with gr.Column(scale=1):
label_box1 = gr.Textbox(label="Label", interactive=False)
with gr.Column(scale=1):
confidence_box1 = gr.Textbox(label="AI Percentage", interactive=False)
with gr.Row():
gr.Markdown("### Result (Code Format) :")
with gr.Row():
with gr.Column(scale=1):
label_box2 = gr.Textbox(label="Label", interactive=False)
with gr.Column(scale=1):
confidence_box2 = gr.Textbox(label="AI Percentage", interactive=False)
# Bind functions
cpp_file.change(fn=load_cpp_file, inputs=cpp_file, outputs=code_box)
check_btn.click(
fn=lambda code: Evaluate1.eval(code) + Evaluate2.eval(code),
inputs=[code_box],
outputs=[label_box1, confidence_box1, label_box2, confidence_box2]
)
web.launch()