Sopipatil commited on
Commit
ce6ee3b
·
1 Parent(s): 0f6dab4

fix: resolve pillow unidentified image error and figure number collisions

Browse files
Files changed (2) hide show
  1. app/main.py +1 -1
  2. streamlit_ui/StreamlitApp.py +6 -2
app/main.py CHANGED
@@ -1262,7 +1262,7 @@ def _resolve_existing_image_path(value: object) -> str:
1262
  elif os.path.exists("/app"):
1263
  rec_path = rec_path.replace("C:/Users/supri/recovered-rag-project", "/app")
1264
 
1265
- if norm_id in record.entity_id or record.entity_id in norm_id:
1266
  path_suffix = Path(rec_path).suffix.lower()
1267
  if path_suffix in [".png", ".jpg", ".jpeg", ".webp", ".gif"] and os.path.exists(rec_path) and os.path.getsize(rec_path) > 1000:
1268
  return rec_path
 
1262
  elif os.path.exists("/app"):
1263
  rec_path = rec_path.replace("C:/Users/supri/recovered-rag-project", "/app")
1264
 
1265
+ if (norm_id in record.entity_id or record.entity_id in norm_id) and match_by_digits_and_category(filename, record.entity_id):
1266
  path_suffix = Path(rec_path).suffix.lower()
1267
  if path_suffix in [".png", ".jpg", ".jpeg", ".webp", ".gif"] and os.path.exists(rec_path) and os.path.getsize(rec_path) > 1000:
1268
  return rec_path
streamlit_ui/StreamlitApp.py CHANGED
@@ -2611,7 +2611,11 @@ def display_image_robustly(img_path: str):
2611
 
2612
  found_path = None
2613
  for path in possible_paths:
2614
- if os.path.exists(path):
 
 
 
 
2615
  found_path = path
2616
  break
2617
 
@@ -2692,7 +2696,7 @@ def _resolve_existing_image_path(value: object) -> str:
2692
  elif os.path.exists("/app"):
2693
  rec_path = rec_path.replace("C:/Users/supri/recovered-rag-project", "/app")
2694
 
2695
- if norm_id in record.entity_id or record.entity_id in norm_id:
2696
  path_suffix = Path(rec_path).suffix.lower()
2697
  if path_suffix in [".png", ".jpg", ".jpeg", ".webp", ".gif"] and os.path.exists(rec_path) and os.path.getsize(rec_path) > 1000:
2698
  return rec_path
 
2611
 
2612
  found_path = None
2613
  for path in possible_paths:
2614
+ is_lfs = False
2615
+ if "assets/extracted_images" in path.lower():
2616
+ if os.path.exists(path) and os.path.getsize(path) <= 1000:
2617
+ is_lfs = True
2618
+ if os.path.exists(path) and not is_lfs:
2619
  found_path = path
2620
  break
2621
 
 
2696
  elif os.path.exists("/app"):
2697
  rec_path = rec_path.replace("C:/Users/supri/recovered-rag-project", "/app")
2698
 
2699
+ if (norm_id in record.entity_id or record.entity_id in norm_id) and match_by_digits_and_category(filename, record.entity_id):
2700
  path_suffix = Path(rec_path).suffix.lower()
2701
  if path_suffix in [".png", ".jpg", ".jpeg", ".webp", ".gif"] and os.path.exists(rec_path) and os.path.getsize(rec_path) > 1000:
2702
  return rec_path