Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
| 11 |
|
| 12 |
-
# 1. Import the
|
| 13 |
from util.omniparser import Omniparser
|
| 14 |
-
from util.utils import
|
| 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
|
| 23 |
-
config =
|
| 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
|
| 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.", "{}"
|