Spaces:
Runtime error
Runtime error
Download app_launcher.py from Netrava/omniparser-api: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/Netrava/omniparser-api/resolve/main/app_launcher.py
- Command line
-
hf download hf://spaces/Netrava/omniparser-api/app_launcher.py
-
curl -L -o app_launcher.py https://huggingface.co/spaces/Netrava/omniparser-api/resolve/main/app_launcher.py
1.33 kB
| import os | |
| import sys | |
| import importlib.util | |
| def check_module(module_name): | |
| """Check if a module can be imported""" | |
| try: | |
| importlib.import_module(module_name) | |
| return True | |
| except ImportError: | |
| return False | |
| def main(): | |
| """ | |
| Determine which app version to launch based on available dependencies | |
| """ | |
| print("Checking environment for OmniParser compatibility...") | |
| # Check for required dependencies | |
| dependencies = { | |
| "torch": check_module("torch"), | |
| "transformers": check_module("transformers"), | |
| "ultralytics": check_module("ultralytics"), | |
| "easyocr": check_module("easyocr"), | |
| "paddleocr": check_module("paddleocr") | |
| } | |
| # Print dependency status | |
| for dep, available in dependencies.items(): | |
| print(f" {dep}: {'✓' if available else '✗'}") | |
| # Decide which version to use | |
| if all([dependencies["torch"], dependencies["transformers"], dependencies["ultralytics"]]): | |
| print("\nUsing full version (app.py)") | |
| # Import and run the full version | |
| import app | |
| else: | |
| print("\nUsing simplified version (app_simplified.py)") | |
| # Import and run the simplified version | |
| import app_simplified | |
| if __name__ == "__main__": | |
| main() |