Update app.py
Browse files
app.py
CHANGED
@@ -780,70 +780,59 @@ def create_interface():
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
-
/*
|
784 |
-
.file
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
|
|
|
|
|
|
|
|
792 |
}
|
793 |
|
794 |
-
/*
|
795 |
-
.file-
|
796 |
-
display:
|
797 |
-
|
798 |
-
|
|
|
|
|
799 |
}
|
800 |
|
801 |
-
/*
|
802 |
-
.file
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
left: 0;
|
807 |
-
width: 100%;
|
808 |
-
height: 50px !important;
|
809 |
-
background-color: #f0f0f0;
|
810 |
-
border: 1px solid #d9d9d9;
|
811 |
-
border-radius: 4px;
|
812 |
-
display: flex !important;
|
813 |
-
align-items: center;
|
814 |
-
justify-content: center;
|
815 |
-
font-size: 14px;
|
816 |
-
cursor: pointer;
|
817 |
-
z-index: 100;
|
818 |
}
|
819 |
|
820 |
-
/*
|
821 |
-
.file
|
822 |
-
|
823 |
-
opacity: 0 !important;
|
824 |
-
visibility: visible !important;
|
825 |
position: absolute !important;
|
826 |
top: 0 !important;
|
827 |
left: 0 !important;
|
828 |
width: 100% !important;
|
829 |
-
height:
|
830 |
-
|
831 |
-
z-index: 200 !important;
|
832 |
}
|
833 |
|
834 |
-
/*
|
835 |
-
.file-
|
836 |
-
content: "
|
837 |
-
position: absolute;
|
838 |
-
bottom: -20px;
|
839 |
-
left: 0;
|
840 |
-
width: 100%;
|
841 |
-
text-align: center;
|
842 |
-
font-size: 12px;
|
843 |
-
color: #999;
|
844 |
display: block !important;
|
845 |
-
|
846 |
-
|
|
|
|
|
|
|
|
|
|
|
847 |
}
|
848 |
"""
|
849 |
|
@@ -867,18 +856,20 @@ def create_interface():
|
|
867 |
|
868 |
# Simple row layout for radio buttons and file upload
|
869 |
with gr.Row():
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
|
|
876 |
|
877 |
-
with
|
|
|
878 |
file_upload = gr.File(
|
879 |
file_types=["image", "pdf", "doc", "docx"],
|
880 |
type="binary",
|
881 |
-
label="
|
882 |
)
|
883 |
|
884 |
# Analyze button
|
@@ -891,14 +882,12 @@ def create_interface():
|
|
891 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
892 |
|
893 |
# Connect components
|
894 |
-
# 1. Analyze button click
|
895 |
analyze_btn.click(
|
896 |
fn=lambda text, mode: analyze_text(text, mode, classifier),
|
897 |
inputs=[text_input, mode_selection],
|
898 |
outputs=[output_html, output_sentences, output_result]
|
899 |
)
|
900 |
|
901 |
-
# 2. File upload change event
|
902 |
file_upload.change(
|
903 |
fn=handle_file_upload_and_analyze,
|
904 |
inputs=[file_upload, mode_selection],
|
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
+
/* Custom styling for the file upload button */
|
784 |
+
.gradio-file {
|
785 |
+
height: 40px !important;
|
786 |
+
display: flex !important;
|
787 |
+
align-items: center !important;
|
788 |
+
justify-content: center !important;
|
789 |
+
background-color: #f0f0f0 !important;
|
790 |
+
border: 1px solid #d9d9d9 !important;
|
791 |
+
border-radius: 4px !important;
|
792 |
+
margin-left: 15px !important;
|
793 |
+
width: 150px !important;
|
794 |
+
position: relative !important;
|
795 |
+
overflow: hidden !important;
|
796 |
}
|
797 |
|
798 |
+
/* Style the upload button label */
|
799 |
+
.gradio-file > div:first-child {
|
800 |
+
display: flex !important;
|
801 |
+
align-items: center !important;
|
802 |
+
justify-content: center !important;
|
803 |
+
height: 100% !important;
|
804 |
+
width: 100% !important;
|
805 |
}
|
806 |
|
807 |
+
/* Hide unnecessary elements */
|
808 |
+
.gradio-file p,
|
809 |
+
.gradio-file .file-preview,
|
810 |
+
.gradio-file svg {
|
811 |
+
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
}
|
813 |
|
814 |
+
/* Make sure the input is accessible to clicks but visually hidden */
|
815 |
+
.gradio-file input[type="file"] {
|
816 |
+
cursor: pointer !important;
|
|
|
|
|
817 |
position: absolute !important;
|
818 |
top: 0 !important;
|
819 |
left: 0 !important;
|
820 |
width: 100% !important;
|
821 |
+
height: 100% !important;
|
822 |
+
opacity: 0 !important;
|
|
|
823 |
}
|
824 |
|
825 |
+
/* Add the text with a pseudo-element */
|
826 |
+
.gradio-file > div:first-child::before {
|
827 |
+
content: "Upload Document" !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
828 |
display: block !important;
|
829 |
+
pointer-events: none !important;
|
830 |
+
}
|
831 |
+
|
832 |
+
/* Ensure the radio buttons and file upload are aligned */
|
833 |
+
.radio-container, .file-container {
|
834 |
+
display: flex !important;
|
835 |
+
align-items: center !important;
|
836 |
}
|
837 |
"""
|
838 |
|
|
|
856 |
|
857 |
# Simple row layout for radio buttons and file upload
|
858 |
with gr.Row():
|
859 |
+
with gr.Column(elem_classes=["radio-container"], scale=3):
|
860 |
+
mode_selection = gr.Radio(
|
861 |
+
choices=["quick", "detailed"],
|
862 |
+
value="quick",
|
863 |
+
label="",
|
864 |
+
show_label=False
|
865 |
+
)
|
866 |
|
867 |
+
# Use an explicit column with a class for file upload
|
868 |
+
with gr.Column(elem_classes=["file-container"], scale=1):
|
869 |
file_upload = gr.File(
|
870 |
file_types=["image", "pdf", "doc", "docx"],
|
871 |
type="binary",
|
872 |
+
label="" # Remove label to use our pseudo-element
|
873 |
)
|
874 |
|
875 |
# Analyze button
|
|
|
882 |
output_result = gr.Textbox(label="Overall Result", lines=4)
|
883 |
|
884 |
# Connect components
|
|
|
885 |
analyze_btn.click(
|
886 |
fn=lambda text, mode: analyze_text(text, mode, classifier),
|
887 |
inputs=[text_input, mode_selection],
|
888 |
outputs=[output_html, output_sentences, output_result]
|
889 |
)
|
890 |
|
|
|
891 |
file_upload.change(
|
892 |
fn=handle_file_upload_and_analyze,
|
893 |
inputs=[file_upload, mode_selection],
|