rwillats commited on
Commit
3c2e3e8
·
verified ·
1 Parent(s): a1e309f

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. hate_speech_demo.py +8 -6
hate_speech_demo.py CHANGED
@@ -742,12 +742,14 @@ def create_gradio_app():
742
  # Add loading spinner
743
  loading_spinner = gr.HTML('<div id="loading-spinner"></div>')
744
 
745
- pdf_path = Path("Hate Speech Policy.pdf")
746
- if pdf_path.exists():
747
- pdf_file = gr.File(pdf_path, visible=False, label="Policy PDF")
748
- else:
749
- # Fallback if PDF doesn't exist
750
- pdf_file = gr.File(None, visible=False, label="Policy PDF")
 
 
751
 
752
  # Add policy popup HTML with reliable PDF loading that works on first click
753
  policy_popup_html = """
 
742
  # Add loading spinner
743
  loading_spinner = gr.HTML('<div id="loading-spinner"></div>')
744
 
745
+ # Replace the PDF file component code with this:
746
+ try:
747
+ # Convert Path object to string explicitly
748
+ pdf_file = gr.File(str("Hate Speech Policy.pdf"), visible=False, label="Policy PDF")
749
+ except Exception as e:
750
+ print(f"Error creating PDF file component: {e}")
751
+ # Fallback if PDF doesn't exist or other error occurs
752
+ pdf_file = gr.File(None, visible=False, label="Policy PDF")
753
 
754
  # Add policy popup HTML with reliable PDF loading that works on first click
755
  policy_popup_html = """