import gradio as gr from relative_tester import relative_tester # from two_sample_tester import two_sample_tester from utils import init_random_seeds init_random_seeds() def run_test(input_text): if not input_text: return "Now that you've built a demo, you'll probably want to share it with others. Gradio demos can be shared in two ways: using a temporary share link or permanent hosting on Spaces." # return two_sample_tester.test(input_text.strip()) return relative_tester.test(input_text.strip()) return f"Prediction: Human (Mocked for {input_text})" # TODO: Add model selection in the future # Change mode name # def change_mode(mode): # if mode == "Faster Model": # .change_mode("t5-small") # elif mode == "Medium Model": # .change_mode("roberta-base-openai-detector") # elif mode == "Powerful Model": # .change_mode("falcon-rw-1b") # else: # gr.Error(f"Invaild mode selected.") # return mode css = """ #header { text-align: center; font-size: 3em; margin-bottom: 20px; } #output-text { font-weight: bold; font-size: 1.2em; } .links { display: flex; justify-content: flex-end; gap: 10px; margin-right: 10px; align-items: center; } .separator { margin: 0 5px; color: black; } /* Adjusting layout for Input Text and Inference Result */ .input-row { display: flex; width: 100%; } .input-text { flex: 3; /* 4 parts of the row */ margin-right: 1px; } .output-text { flex: 1; /* 1 part of the row */ } /* Set button widths to match the Select Model width */ .button { width: 250px; /* Same as the select box width */ height: 100px; /* Button height */ } /* Set height for the Select Model dropdown */ .select { height: 100px; /* Set height to 100px */ } /* Accordion Styling */ .accordion { width: 100%; /* Set the width of the accordion to match the parent */ max-height: 200px; /* Set a max-height for accordion */ overflow-y: auto; /* Allow scrolling if the content exceeds max height */ margin-bottom: 10px; /* Add space below accordion */ box-sizing: border-box; /* Ensure padding is included in width/height */ } /* Accordion content max-height */ .accordion-content { max-height: 200px; /* Limit the height of the content */ overflow-y: auto; /* Add a scrollbar if content overflows */ } """ # Gradio App with gr.Blocks(css=css) as app: with gr.Row(): gr.HTML('