billusanda007 commited on
Commit
1efe151
·
verified ·
1 Parent(s): 524d0a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -29,12 +29,21 @@ def pdf_to_text(file):
29
  text = "\n".join([pytesseract.image_to_string(img) for img in images])
30
  return text
31
 
 
 
32
  def fix_h5_model():
33
  with h5py.File("deeprank_model_v2.h5", "r+") as f:
34
  if "model_config" in f.attrs:
35
  model_config = f.attrs["model_config"]
36
- updated_config = model_config.replace(b'"time_major": false', b"")
37
- f.attrs.modify("model_config", updated_config)
 
 
 
 
 
 
 
38
 
39
  def load_deeprank_model():
40
  fix_h5_model()
 
29
  text = "\n".join([pytesseract.image_to_string(img) for img in images])
30
  return text
31
 
32
+ import h5py
33
+
34
  def fix_h5_model():
35
  with h5py.File("deeprank_model_v2.h5", "r+") as f:
36
  if "model_config" in f.attrs:
37
  model_config = f.attrs["model_config"]
38
+
39
+ # Ensure model_config is a string before replacing
40
+ if isinstance(model_config, bytes):
41
+ model_config = model_config.decode("utf-8")
42
+
43
+ updated_config = model_config.replace('"time_major": false', "")
44
+
45
+ # Store the updated config back as bytes
46
+ f.attrs.modify("model_config", updated_config.encode("utf-8"))
47
 
48
  def load_deeprank_model():
49
  fix_h5_model()