Spaces:
Runtime error
Runtime error
Download app.py from GiantPandas/Infinity-Parser2-Demo: direct link, hf CLI and curl.
- Browser
- Download file 915 Bytes
-
https://huggingface.co/spaces/GiantPandas/Infinity-Parser2-Demo/resolve/main/app.py
- Command line
-
hf download hf://spaces/GiantPandas/Infinity-Parser2-Demo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/GiantPandas/Infinity-Parser2-Demo/resolve/main/app.py
915 Bytes
| import os | |
| import sys | |
| import subprocess | |
| from loguru import logger | |
| def setup_and_run(): | |
| repo_url = "https://github.com/infly-ai/INF-MLLM.git" | |
| clone_dir = "INF-MLLM" | |
| repo_dir = "INF-MLLM/Infinity-Parser2/infinity_parser2" | |
| if not os.path.exists(clone_dir): | |
| logger.info(f"clone: {repo_url}") | |
| subprocess.run(["git", "clone", repo_url], check=True) | |
| else: | |
| logger.info("pulling...") | |
| subprocess.run(["git", "pull"], cwd=clone_dir, check=True) | |
| os.environ['GRADIO_SSR_MODE'] = "false" | |
| os.environ["GRADIO_SERVER_PORT"] = "7860" | |
| os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0" | |
| logger.info("run gradio_app.py ...") | |
| try: | |
| subprocess.run([sys.executable, "gradio_app.py"], cwd=repo_dir, check=True) | |
| except subprocess.CalledProcessError as e: | |
| logger.error(f"Gradio exit: {e}") | |
| if __name__ == "__main__": | |
| setup_and_run() |