Netrava commited on
Commit
dec2f20
Β·
verified Β·
1 Parent(s): f9ea44f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -7,11 +7,11 @@ import torch
7
  # This part is correct and finds the project files.
8
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
9
 
10
- # --- START OF THE FINAL CORRECTED INITIALIZATION (Based on official demo) ---
11
 
12
- # 1. Import the correct class and helper objects from the project's own files.
13
  from util.omniparser import Omniparser
14
- from util.utils import VLP_MODEL_CONFIG, get_model_path
15
 
16
  print("Initializing...")
17
 
@@ -19,15 +19,15 @@ print("Initializing...")
19
  model_name_key = get_model_path("omniparser-v2-effnet")
20
  print(f"Resolved model name to key: {model_name_key}")
21
 
22
- # 3. Get the correct configuration dictionary from the VLP_MODEL_CONFIG constant.
23
- config = VLP_MODEL_CONFIG[model_name_key]
24
  print("βœ… Configuration dictionary loaded successfully.")
25
 
26
  # 4. Pass the CONFIG DICTIONARY to the class constructor.
27
  parser_instance = Omniparser(config)
28
  print("βœ… OmniParser model loaded successfully.")
29
 
30
- # --- END OF THE FINAL CORRECTED INITIALIZATION ---
31
 
32
  def parse_document(input_file):
33
  if input_file is None: return "Please upload a document.", "{}"
 
7
  # This part is correct and finds the project files.
8
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
9
 
10
+ # --- START OF THE FINAL, VERIFIED INITIALIZATION ---
11
 
12
+ # 1. Import the class and the CORRECTLY NAMED config dictionary and helper function.
13
  from util.omniparser import Omniparser
14
+ from util.utils import MODEL_CONFIG, get_model_path # CORRECTED VARIABLE NAME
15
 
16
  print("Initializing...")
17
 
 
19
  model_name_key = get_model_path("omniparser-v2-effnet")
20
  print(f"Resolved model name to key: {model_name_key}")
21
 
22
+ # 3. Get the correct configuration dictionary from the MODEL_CONFIG constant.
23
+ config = MODEL_CONFIG[model_name_key] # CORRECTED VARIABLE NAME
24
  print("βœ… Configuration dictionary loaded successfully.")
25
 
26
  # 4. Pass the CONFIG DICTIONARY to the class constructor.
27
  parser_instance = Omniparser(config)
28
  print("βœ… OmniParser model loaded successfully.")
29
 
30
+ # --- END OF THE FINAL, VERIFIED INITIALIZATION ---
31
 
32
  def parse_document(input_file):
33
  if input_file is None: return "Please upload a document.", "{}"