ApsidalSolid4 commited on
Commit
7361b7e
·
verified ·
1 Parent(s): 3e303a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -24
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 properly sized file upload button
774
  def create_interface():
775
  # Custom CSS for the interface
776
  css = """
@@ -780,49 +780,64 @@ def create_interface():
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,14 +868,11 @@ def create_interface():
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
 
770
  # Initialize the classifier globally
771
  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 = """
 
780
  color: white !important;
781
  }
782
 
783
+ /* Make upload button container match radio button container size */
784
  .file-upload-container {
785
  margin-left: 15px;
786
+ width: 150px;
787
+ height: 40px;
788
  display: inline-block;
789
  vertical-align: middle;
790
+ position: relative;
791
  }
792
 
793
+ /* Hide ALL the default file upload elements */
794
+ .file-upload-container .file-preview,
795
+ .file-upload-container .file-drop,
796
+ .file-upload-container p,
797
+ .file-upload-container svg,
798
+ .file-upload-container [data-testid="chunkFileDropArea"],
799
+ .file-upload-container [data-testid="droparea"] {
800
  display: none !important;
801
  }
802
 
803
+ /* Style the button to look exactly like we want */
804
+ .file-upload-container > div:last-child {
805
+ position: absolute !important;
806
+ top: 0 !important;
807
+ left: 0 !important;
808
+ width: 100% !important;
809
  height: 40px !important;
810
+ padding: 0 15px !important;
811
  background-color: #f0f0f0 !important;
812
  border: 1px solid #d9d9d9 !important;
813
  border-radius: 4px !important;
814
  display: flex !important;
815
  align-items: center !important;
816
  justify-content: center !important;
 
817
  margin: 0 !important;
818
  }
819
 
820
+ /* Style the button text */
821
+ .file-upload-container label span {
 
 
 
 
 
 
 
822
  font-size: 14px !important;
823
+ font-weight: normal !important;
824
+ margin: 0 !important;
825
+ display: inline-block !important;
826
  }
827
 
828
  /* Hover effect */
829
+ .file-upload-container > div:last-child:hover {
830
  background-color: #e0e0e0 !important;
831
+ }
832
+
833
+ /* Hide any additional elements that might appear */
834
+ .file-upload-container * {
835
+ margin: 0 !important;
836
+ }
837
+
838
+ /* Hide the file selection area */
839
+ .file-upload-container div[data-testid="block"] > div[data-testid="droparea"] {
840
+ display: none !important;
841
  }
842
  """
843
 
 
868
  show_label=False
869
  )
870
 
 
871
  with gr.Column(elem_classes=["file-upload-container"], scale=0):
872
  file_upload = gr.File(
873
  file_types=["image", "pdf", "doc", "docx"],
874
  type="binary",
875
+ label="Upload Document"
 
 
876
  )
877
 
878
  # Analyze button