G-Madhuri commited on
Commit
82c57ae
·
verified ·
1 Parent(s): b995d2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -10,7 +10,13 @@ from PIL import Image
10
  import numpy as np
11
 
12
  # =========================
13
- # Auto-unzip parseq.zip if it exists (ONLY ADDITION)
 
 
 
 
 
 
14
  # =========================
15
  if os.path.exists('parseq.zip'):
16
  print("Found parseq.zip, extracting...")
@@ -34,8 +40,6 @@ if os.path.exists(parseq_path):
34
  sys.path.insert(0, parseq_path)
35
  else:
36
  logger.error(f"PARSeq not found at {parseq_path}")
37
- # Don't exit, try to continue
38
- print(f"WARNING: PARSeq folder not found at {parseq_path}")
39
 
40
  try:
41
  from strhub.data.utils import Tokenizer
@@ -43,7 +47,6 @@ try:
43
  print("✅ Successfully imported Tokenizer")
44
  except ImportError as e:
45
  print(f"Import error: {e}")
46
- # Create a simple tokenizer as fallback
47
  class Tokenizer:
48
  def __init__(self, chars):
49
  self.charset = chars
 
10
  import numpy as np
11
 
12
  # =========================
13
+ # Download nltk data (required by PARSeq)
14
+ # =========================
15
+ import nltk
16
+ nltk.download('punkt', quiet=True)
17
+
18
+ # =========================
19
+ # Auto-unzip parseq.zip if it exists
20
  # =========================
21
  if os.path.exists('parseq.zip'):
22
  print("Found parseq.zip, extracting...")
 
40
  sys.path.insert(0, parseq_path)
41
  else:
42
  logger.error(f"PARSeq not found at {parseq_path}")
 
 
43
 
44
  try:
45
  from strhub.data.utils import Tokenizer
 
47
  print("✅ Successfully imported Tokenizer")
48
  except ImportError as e:
49
  print(f"Import error: {e}")
 
50
  class Tokenizer:
51
  def __init__(self, chars):
52
  self.charset = chars