File size: 778 Bytes
e12b49b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Launch AIM

import subprocess
import os
from huggingface_hub import hf_hub_download
import gradio as gr

PORT = 3000
HOST = "localhost"

REPO_ID = "muellerzr/bert-base-cased-tpu-accelerate-experiments"

def download_logs():
    filename = "aim_logs.zip"
    _ = hf_hub_download(
        repo_id=REPO_ID,
        repo_type="model",
        filename=filename,
    )
    subprocess.run("unzip aim_logs.zip")

def run_aim():
    cmd = f"aim up --repo aim_logs --host {HOST} --port {PORT}"
    os.spawnl(os.P_DETACH, cmd)

html = f"""
<iframe src="https://{HOST}:{port}"></iframe>
"""

def run():
    download_logs()
    run_aim()

def main():
    demo = gr.Interface(
        fn=run, 
        outputs=gr.HTML(html)
    )

    demo.launch()

if __name__ == "__main__":
    main()