Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -770,7 +770,7 @@ def analyze_text(text: str, mode: str, classifier: TextClassifier) -> tuple:
|
|
770 |
# Initialize the classifier globally
|
771 |
classifier = TextClassifier()
|
772 |
|
773 |
-
# Create Gradio interface with a file upload button
|
774 |
def create_interface():
|
775 |
# Custom CSS for the interface
|
776 |
css = """
|
@@ -780,50 +780,49 @@ def create_interface():
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
-
/* Style the file upload container */
|
784 |
.file-upload-container {
|
785 |
margin-left: 15px;
|
786 |
display: inline-block;
|
787 |
-
vertical-align:
|
788 |
}
|
789 |
|
790 |
-
/* Hide
|
791 |
-
.file-upload-container .file-preview
|
792 |
-
.file-upload-container p:not(.drop-text),
|
793 |
-
.file-upload-container svg,
|
794 |
-
.file-upload-container label span {
|
795 |
display: none !important;
|
796 |
}
|
797 |
|
798 |
-
/* Style the
|
799 |
.file-upload-container [data-testid="chunkFileDropArea"] {
|
|
|
|
|
800 |
background-color: #f0f0f0 !important;
|
801 |
border: 1px solid #d9d9d9 !important;
|
802 |
border-radius: 4px !important;
|
803 |
-
height: 42px !important; /* Slightly taller to align with radio buttons */
|
804 |
-
padding: 10px 15px !important;
|
805 |
display: flex !important;
|
806 |
align-items: center !important;
|
807 |
-
justify-content:
|
808 |
-
|
809 |
-
}
|
810 |
-
|
811 |
-
/* Style the drop text */
|
812 |
-
.file-upload-container .drop-text {
|
813 |
margin: 0 !important;
|
814 |
-
font-size: 14px !important;
|
815 |
-
font-weight: normal !important;
|
816 |
-
color: #555 !important;
|
817 |
}
|
818 |
|
819 |
-
/*
|
820 |
-
.file-upload-container
|
821 |
display: none !important;
|
822 |
}
|
823 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
824 |
/* Hover effect */
|
825 |
.file-upload-container [data-testid="chunkFileDropArea"]:hover {
|
826 |
background-color: #e0e0e0 !important;
|
|
|
827 |
}
|
828 |
"""
|
829 |
|
@@ -854,14 +853,14 @@ def create_interface():
|
|
854 |
show_label=False
|
855 |
)
|
856 |
|
|
|
857 |
with gr.Column(elem_classes=["file-upload-container"], scale=0):
|
858 |
-
# Add a special class to identify and style the drop text
|
859 |
-
gr.HTML("<p class='drop-text'>Drop File Here</p>", visible=False)
|
860 |
-
|
861 |
file_upload = gr.File(
|
862 |
file_types=["image", "pdf", "doc", "docx"],
|
863 |
type="binary",
|
864 |
-
label=""
|
|
|
|
|
865 |
)
|
866 |
|
867 |
# Analyze button
|
|
|
770 |
# Initialize the classifier globally
|
771 |
classifier = TextClassifier()
|
772 |
|
773 |
+
# Create Gradio interface with a properly sized file upload button
|
774 |
def create_interface():
|
775 |
# Custom CSS for the interface
|
776 |
css = """
|
|
|
780 |
color: white !important;
|
781 |
}
|
782 |
|
783 |
+
/* Style the file upload container to match the radio buttons */
|
784 |
.file-upload-container {
|
785 |
margin-left: 15px;
|
786 |
display: inline-block;
|
787 |
+
vertical-align: middle;
|
788 |
}
|
789 |
|
790 |
+
/* Hide file info and preview */
|
791 |
+
.file-upload-container .file-preview {
|
|
|
|
|
|
|
792 |
display: none !important;
|
793 |
}
|
794 |
|
795 |
+
/* Style the upload button to a proper size */
|
796 |
.file-upload-container [data-testid="chunkFileDropArea"] {
|
797 |
+
width: 150px !important;
|
798 |
+
height: 40px !important;
|
799 |
background-color: #f0f0f0 !important;
|
800 |
border: 1px solid #d9d9d9 !important;
|
801 |
border-radius: 4px !important;
|
|
|
|
|
802 |
display: flex !important;
|
803 |
align-items: center !important;
|
804 |
+
justify-content: center !important;
|
805 |
+
padding: 0 10px !important;
|
|
|
|
|
|
|
|
|
806 |
margin: 0 !important;
|
|
|
|
|
|
|
807 |
}
|
808 |
|
809 |
+
/* Show only the "Upload Document" text */
|
810 |
+
.file-upload-container [data-testid="chunkFileDropArea"] * {
|
811 |
display: none !important;
|
812 |
}
|
813 |
|
814 |
+
/* Add a new label */
|
815 |
+
.file-upload-container [data-testid="chunkFileDropArea"]::before {
|
816 |
+
content: "Upload Document" !important;
|
817 |
+
display: block !important;
|
818 |
+
font-size: 14px !important;
|
819 |
+
color: #444 !important;
|
820 |
+
}
|
821 |
+
|
822 |
/* Hover effect */
|
823 |
.file-upload-container [data-testid="chunkFileDropArea"]:hover {
|
824 |
background-color: #e0e0e0 !important;
|
825 |
+
cursor: pointer !important;
|
826 |
}
|
827 |
"""
|
828 |
|
|
|
853 |
show_label=False
|
854 |
)
|
855 |
|
856 |
+
# File upload component with compact styling
|
857 |
with gr.Column(elem_classes=["file-upload-container"], scale=0):
|
|
|
|
|
|
|
858 |
file_upload = gr.File(
|
859 |
file_types=["image", "pdf", "doc", "docx"],
|
860 |
type="binary",
|
861 |
+
label="",
|
862 |
+
show_label=False,
|
863 |
+
elem_id="file-upload"
|
864 |
)
|
865 |
|
866 |
# Analyze button
|