RangGaraga commited on
Commit
ae82d7e
Β·
verified Β·
1 Parent(s): 7f34946

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- import fitz # PyMuPDF
4
  import tempfile
5
  import os
6
 
@@ -79,7 +79,7 @@ LABEL_HEX = {
79
 
80
  MAX_PDF_PAGES = 5
81
 
82
- # ─── Example texts ────────────────────────────────────────────────────────────
83
  EXAMPLES = [
84
  (
85
  "Contoh 1 – RUPS & Dana Cadangan",
@@ -259,7 +259,7 @@ def run_ner_pdf(pdf_file):
259
  # Track which labels actually appeared
260
  found_labels: set[str] = set()
261
 
262
- # ── Highlight each page ────────────────────────────────────────────────────
263
  for page in doc:
264
  for word, label_id in sorted_entities:
265
  color = LABEL_COLORS.get(label_id, (0.9, 0.9, 0.9))
@@ -270,7 +270,7 @@ def run_ner_pdf(pdf_file):
270
  annot.update()
271
  found_labels.add(label_id)
272
 
273
- # ── Save to temp file ─────────────────────────────────────────────────────
274
  out_fd, out_path = tempfile.mkstemp(suffix=".pdf")
275
  os.close(out_fd)
276
  doc.save(out_path)
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ import fitz
4
  import tempfile
5
  import os
6
 
 
79
 
80
  MAX_PDF_PAGES = 5
81
 
82
+ # Example texts
83
  EXAMPLES = [
84
  (
85
  "Contoh 1 – RUPS & Dana Cadangan",
 
259
  # Track which labels actually appeared
260
  found_labels: set[str] = set()
261
 
262
+ # Highlight each page
263
  for page in doc:
264
  for word, label_id in sorted_entities:
265
  color = LABEL_COLORS.get(label_id, (0.9, 0.9, 0.9))
 
270
  annot.update()
271
  found_labels.add(label_id)
272
 
273
+ # Save to temp file
274
  out_fd, out_path = tempfile.mkstemp(suffix=".pdf")
275
  os.close(out_fd)
276
  doc.save(out_path)