File size: 1,397 Bytes
52da96f
88c6453
52da96f
 
 
 
40ee819
 
52da96f
88c6453
 
 
52da96f
 
 
 
 
 
 
 
 
40ee819
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c4a4a8
8fdbefd
40ee819
 
 
52da96f
40ee819
 
 
52da96f
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
root_dir = __file__.rsplit("/", 1)[0]
if root_dir not in sys.path:
    sys.path.append(root_dir)

import gradio as gr
import asyncio
import os

from demo.modules.search import build_search_module
from demo.modules.compute_score import build_score_computation
from demo.modules.tmalign import build_TMalign


# Build demo
with gr.Blocks() as demo:
    build_search_module()
    build_score_computation()
    build_TMalign()


# Asynchronously download the required index files
async def run_cmd(cmd):
    process = await asyncio.create_subprocess_shell(
        cmd,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE
    )
    stdout, stderr = await process.communicate()
    print(f'[{cmd!r} exited with {process.returncode}]')
    if stdout:
        print(f'[stdout]\n{stdout.decode()}')
    if stderr:
        print(f'[stderr]\n{stderr.decode()}')


async def download_faiss_index():
    await asyncio.gather(
        run_cmd("echo Hello World!"),
        run_cmd('huggingface-cli download westlake-repl/ProTrek-faiss-index  --repo-type dataset  --local-dir /data/ProTrek-faiss-index --include "ProTrek_650M_UniRef50/UniRef50/*"'),
    )


if __name__ == '__main__':
    # Run the async function to download the index files
    asyncio.run(download_faiss_index())
    
    # Run the demo
    demo.launch()