ApsidalSolid4 commited on
Commit
3820ea8
·
verified ·
1 Parent(s): e62585f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -61
app.py CHANGED
@@ -780,70 +780,59 @@ def create_interface():
780
  color: white !important;
781
  }
782
 
783
- /* Container for the file upload */
784
- .file-upload-container {
785
- margin-left: 15px;
786
- width: 150px;
787
- height: 50px !important; /* Increased height significantly */
788
- display: inline-block;
789
- vertical-align: middle;
790
- position: relative;
791
- overflow: hidden !important; /* Prevent content from spilling out */
 
 
 
 
792
  }
793
 
794
- /* Completely hide ALL elements within the container first */
795
- .file-upload-container * {
796
- display: none !important;
797
- opacity: 0 !important;
798
- visibility: hidden !important;
 
 
799
  }
800
 
801
- /* Then create a custom button overlay that replaces everything */
802
- .file-upload-container::after {
803
- content: "Upload Document";
804
- position: absolute;
805
- top: 0;
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
- /* Show only the actual input element to keep it functional, but make it cover the full area */
821
- .file-upload-container input[type="file"] {
822
- display: block !important;
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: 50px !important;
830
- cursor: pointer !important;
831
- z-index: 200 !important;
832
  }
833
 
834
- /* Style the "- or -" text */
835
- .file-upload-container::before {
836
- content: "- or -";
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
- visibility: visible !important;
846
- opacity: 1 !important;
 
 
 
 
 
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
- mode_selection = gr.Radio(
871
- choices=["quick", "detailed"],
872
- value="quick",
873
- label="",
874
- show_label=False
875
- )
 
876
 
877
- with gr.Column(elem_classes=["file-upload-container"], scale=0):
 
878
  file_upload = gr.File(
879
  file_types=["image", "pdf", "doc", "docx"],
880
  type="binary",
881
- label="Upload Document"
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],