File size: 915 Bytes
4ce053f
 
 
544bc94
4ce053f
544bc94
 
 
 
4ce053f
544bc94
 
 
4ce053f
544bc94
 
4ce053f
544bc94
 
 
4ce053f
43709a0
95e350e
4ce053f
544bc94
 
 
8a44944
4ce053f
544bc94
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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()