Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -772,7 +772,7 @@ classifier = TextClassifier()
|
|
772 |
|
773 |
# Create Gradio interface with a file upload button matched to the radio buttons
|
774 |
def create_interface():
|
775 |
-
# Custom CSS for the interface
|
776 |
css = """
|
777 |
#analyze-btn {
|
778 |
background-color: #FF8C00 !important;
|
@@ -780,30 +780,46 @@ def create_interface():
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
-
/* Style file upload
|
784 |
-
.upload
|
785 |
-
|
786 |
-
margin-left: 15px;
|
787 |
-
vertical-align: middle;
|
788 |
}
|
789 |
|
790 |
-
/*
|
791 |
-
.upload-
|
792 |
-
|
793 |
-
|
|
|
|
|
|
|
794 |
}
|
795 |
|
796 |
-
/*
|
797 |
-
.upload
|
798 |
height: 40px !important;
|
799 |
-
|
800 |
background-color: #f0f0f0 !important;
|
801 |
-
color: #333 !important;
|
802 |
border: 1px solid #d9d9d9 !important;
|
|
|
|
|
803 |
font-size: 14px !important;
|
804 |
-
|
805 |
-
|
|
|
806 |
margin: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
}
|
808 |
"""
|
809 |
|
@@ -825,7 +841,7 @@ def create_interface():
|
|
825 |
gr.Markdown("Analysis Mode")
|
826 |
gr.Markdown("Quick mode for faster analysis. Detailed mode for sentence-level analysis.")
|
827 |
|
828 |
-
# Simple row layout for radio buttons
|
829 |
with gr.Row():
|
830 |
mode_selection = gr.Radio(
|
831 |
choices=["quick", "detailed"],
|
@@ -834,13 +850,13 @@ def create_interface():
|
|
834 |
show_label=False
|
835 |
)
|
836 |
|
837 |
-
# File
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
|
845 |
# Analyze button
|
846 |
analyze_btn = gr.Button("Analyze Text", elem_id="analyze-btn")
|
@@ -858,9 +874,9 @@ def create_interface():
|
|
858 |
outputs=[output_html, output_sentences, output_result]
|
859 |
)
|
860 |
|
861 |
-
#
|
862 |
-
file_upload.
|
863 |
-
fn=
|
864 |
inputs=[file_upload, mode_selection],
|
865 |
outputs=[output_html, output_sentences, output_result]
|
866 |
)
|
|
|
772 |
|
773 |
# Create Gradio interface with a file upload button matched to the radio buttons
|
774 |
def create_interface():
|
775 |
+
# Custom CSS for the interface
|
776 |
css = """
|
777 |
#analyze-btn {
|
778 |
background-color: #FF8C00 !important;
|
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
+
/* Style the file upload to be more compact */
|
784 |
+
.file-upload {
|
785 |
+
width: 150px !important;
|
786 |
+
margin-left: 15px !important;
|
|
|
787 |
}
|
788 |
|
789 |
+
/* Hide file preview elements */
|
790 |
+
.file-upload .file-preview,
|
791 |
+
.file-upload p:not(.file-upload p:first-child),
|
792 |
+
.file-upload svg,
|
793 |
+
.file-upload [data-testid="chunkFileDropArea"],
|
794 |
+
.file-upload .file-drop {
|
795 |
+
display: none !important;
|
796 |
}
|
797 |
|
798 |
+
/* Style the upload button */
|
799 |
+
.file-upload button {
|
800 |
height: 40px !important;
|
801 |
+
width: 100% !important;
|
802 |
background-color: #f0f0f0 !important;
|
|
|
803 |
border: 1px solid #d9d9d9 !important;
|
804 |
+
border-radius: 4px !important;
|
805 |
+
color: #333 !important;
|
806 |
font-size: 14px !important;
|
807 |
+
display: flex !important;
|
808 |
+
align-items: center !important;
|
809 |
+
justify-content: center !important;
|
810 |
margin: 0 !important;
|
811 |
+
padding: 0 !important;
|
812 |
+
}
|
813 |
+
|
814 |
+
/* Hide the "or" text */
|
815 |
+
.file-upload .or {
|
816 |
+
display: none !important;
|
817 |
+
}
|
818 |
+
|
819 |
+
/* Make the container compact */
|
820 |
+
.file-upload [data-testid="block"] {
|
821 |
+
margin: 0 !important;
|
822 |
+
padding: 0 !important;
|
823 |
}
|
824 |
"""
|
825 |
|
|
|
841 |
gr.Markdown("Analysis Mode")
|
842 |
gr.Markdown("Quick mode for faster analysis. Detailed mode for sentence-level analysis.")
|
843 |
|
844 |
+
# Simple row layout for radio buttons and file upload
|
845 |
with gr.Row():
|
846 |
mode_selection = gr.Radio(
|
847 |
choices=["quick", "detailed"],
|
|
|
850 |
show_label=False
|
851 |
)
|
852 |
|
853 |
+
# Revert to File component but with better styling
|
854 |
+
file_upload = gr.File(
|
855 |
+
file_types=["image", "pdf", "doc", "docx"],
|
856 |
+
type="binary",
|
857 |
+
label="Upload Document",
|
858 |
+
elem_classes=["file-upload"]
|
859 |
+
)
|
860 |
|
861 |
# Analyze button
|
862 |
analyze_btn = gr.Button("Analyze Text", elem_id="analyze-btn")
|
|
|
874 |
outputs=[output_html, output_sentences, output_result]
|
875 |
)
|
876 |
|
877 |
+
# Use the original file upload handler
|
878 |
+
file_upload.change(
|
879 |
+
fn=handle_file_upload_and_analyze,
|
880 |
inputs=[file_upload, mode_selection],
|
881 |
outputs=[output_html, output_sentences, output_result]
|
882 |
)
|