Update app.py
Browse files
app.py
CHANGED
|
@@ -802,6 +802,13 @@ def setup_gradio_interface(classifier):
|
|
| 802 |
"""
|
| 803 |
import gradio as gr
|
| 804 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 805 |
with gr.Blocks(title="AI Text Detector") as demo:
|
| 806 |
gr.Markdown("# AI Text Detector with Document Upload")
|
| 807 |
gr.Markdown("Analyze text to detect if it was written by a human or AI. You can paste text directly or upload images, PDFs, or Word documents.")
|
|
@@ -826,9 +833,10 @@ def setup_gradio_interface(classifier):
|
|
| 826 |
output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
| 827 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
| 828 |
|
|
|
|
| 829 |
text_submit_button.click(
|
| 830 |
-
|
| 831 |
-
inputs=[text_input, mode_selection
|
| 832 |
outputs=[output_html, output_sentences, output_result]
|
| 833 |
)
|
| 834 |
|
|
@@ -852,9 +860,10 @@ def setup_gradio_interface(classifier):
|
|
| 852 |
file_output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
| 853 |
file_output_result = gr.Textbox(label="Overall Result", lines=4)
|
| 854 |
|
|
|
|
| 855 |
upload_submit_button.click(
|
| 856 |
-
|
| 857 |
-
inputs=[file_upload, file_mode_selection
|
| 858 |
outputs=[file_output_html, file_output_sentences, file_output_result]
|
| 859 |
)
|
| 860 |
|
|
|
|
| 802 |
"""
|
| 803 |
import gradio as gr
|
| 804 |
|
| 805 |
+
# Create analyzer functions that capture the classifier
|
| 806 |
+
def analyze_text_wrapper(text, mode):
|
| 807 |
+
return analyze_text(text, mode, classifier)
|
| 808 |
+
|
| 809 |
+
def handle_file_upload_wrapper(file_obj, mode):
|
| 810 |
+
return handle_file_upload_and_analyze(file_obj, mode, classifier)
|
| 811 |
+
|
| 812 |
with gr.Blocks(title="AI Text Detector") as demo:
|
| 813 |
gr.Markdown("# AI Text Detector with Document Upload")
|
| 814 |
gr.Markdown("Analyze text to detect if it was written by a human or AI. You can paste text directly or upload images, PDFs, or Word documents.")
|
|
|
|
| 833 |
output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
| 834 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
| 835 |
|
| 836 |
+
# FIXED: Use wrapper function that doesn't include classifier as a parameter
|
| 837 |
text_submit_button.click(
|
| 838 |
+
analyze_text_wrapper,
|
| 839 |
+
inputs=[text_input, mode_selection],
|
| 840 |
outputs=[output_html, output_sentences, output_result]
|
| 841 |
)
|
| 842 |
|
|
|
|
| 860 |
file_output_sentences = gr.Textbox(label="Sentence-by-Sentence Analysis", lines=10)
|
| 861 |
file_output_result = gr.Textbox(label="Overall Result", lines=4)
|
| 862 |
|
| 863 |
+
# FIXED: Use wrapper function that doesn't include classifier as a parameter
|
| 864 |
upload_submit_button.click(
|
| 865 |
+
handle_file_upload_wrapper,
|
| 866 |
+
inputs=[file_upload, file_mode_selection],
|
| 867 |
outputs=[file_output_html, file_output_sentences, file_output_result]
|
| 868 |
)
|
| 869 |
|