Spaces:
Running
Running
| import os | |
| import sys | |
| import subprocess | |
| from loguru import logger | |
| def setup_and_run(): | |
| repo_url = "https://github.com/renkexuan369/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 inf_gradio.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() |