heerjtdev commited on
Commit
6449406
Β·
verified Β·
1 Parent(s): 64b8b98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -16
app.py CHANGED
@@ -168,7 +168,6 @@
168
 
169
 
170
 
171
-
172
  import gradio as gr
173
  print("GRADIO VERSION:", gr.__version__)
174
  import json
@@ -193,18 +192,12 @@ html, body, * {
193
  }
194
  """
195
 
196
- # Write the CSS file if not exists
197
  if not os.path.exists("custom.css"):
198
  with open("custom.css", "w") as f:
199
  f.write(CUSTOM_CSS)
200
  # ==============================
201
 
202
-
203
-
204
- # NOTE: You must ensure that 'working_yolo_pipeline.py' exists
205
- # and defines the following items correctly:
206
- from working_yolo_pipeline import run_document_pipeline, DEFAULT_LAYOUTLMV3_MODEL_PATH, WEIGHTS_PATH
207
-
208
  try:
209
  from working_yolo_pipeline import run_document_pipeline, DEFAULT_LAYOUTLMV3_MODEL_PATH, WEIGHTS_PATH
210
  except ImportError:
@@ -216,9 +209,6 @@ except ImportError:
216
 
217
 
218
  def process_pdf(pdf_file, layoutlmv3_model_path=None):
219
- """
220
- Wrapper function for Gradio interface.
221
- """
222
  if pdf_file is None:
223
  return "❌ Error: No PDF file uploaded.", None
224
 
@@ -253,13 +243,9 @@ def process_pdf(pdf_file, layoutlmv3_model_path=None):
253
  return f"❌ Error during processing: {str(e)}", None
254
 
255
 
256
-
257
- # ======================
258
- # CREATE THE GRADIO UI
259
- # ======================
260
  with gr.Blocks(
261
  title="Document Analysis Pipeline",
262
- css_paths=["custom.css"] # <── IMPORTANT FOR CUSTOM FONTS
263
  ) as demo:
264
 
265
  gr.Markdown("""
 
168
 
169
 
170
 
 
171
  import gradio as gr
172
  print("GRADIO VERSION:", gr.__version__)
173
  import json
 
192
  }
193
  """
194
 
195
+ # Optionally write the CSS file if needed (not required for inline css)
196
  if not os.path.exists("custom.css"):
197
  with open("custom.css", "w") as f:
198
  f.write(CUSTOM_CSS)
199
  # ==============================
200
 
 
 
 
 
 
 
201
  try:
202
  from working_yolo_pipeline import run_document_pipeline, DEFAULT_LAYOUTLMV3_MODEL_PATH, WEIGHTS_PATH
203
  except ImportError:
 
209
 
210
 
211
  def process_pdf(pdf_file, layoutlmv3_model_path=None):
 
 
 
212
  if pdf_file is None:
213
  return "❌ Error: No PDF file uploaded.", None
214
 
 
243
  return f"❌ Error during processing: {str(e)}", None
244
 
245
 
 
 
 
 
246
  with gr.Blocks(
247
  title="Document Analysis Pipeline",
248
+ css=CUSTOM_CSS # <-- here is the fix, inline CSS string instead of css_paths
249
  ) as demo:
250
 
251
  gr.Markdown("""