muellerzr HF staff commited on
Commit
1c27b73
1 Parent(s): 9f6dc18

Use 0.0.0.0?

Browse files
Files changed (1) hide show
  1. app.py +44 -4
app.py CHANGED
@@ -7,22 +7,62 @@ import gradio as gr
7
  import time
8
 
9
  PORT = 7860
10
- HOST = "localhost"
11
 
12
  REPO_ID = "muellerzr/bert-base-cased-tpu-accelerate-experiments"
13
 
 
 
 
 
 
 
 
 
 
 
14
  def run_aim():
15
  cmd = f"aim up --host {HOST} --port {PORT}".split()
16
  subprocess.Popen(cmd)
17
 
 
 
 
 
 
 
18
 
19
- if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  run_aim()
 
21
  demo = gr.Interface(
22
  fn=run,
23
  inputs=[],
24
- outputs=gr.Text("Hello there!")
25
  )
 
26
  demo.launch()
27
-
 
 
28
 
 
7
  import time
8
 
9
  PORT = 7860
10
+ HOST = "0.0.0.0"
11
 
12
  REPO_ID = "muellerzr/bert-base-cased-tpu-accelerate-experiments"
13
 
14
+ def download_logs():
15
+ filename = "aim_logs.zip"
16
+ f = hf_hub_download(
17
+ repo_id=REPO_ID,
18
+ repo_type="model",
19
+ filename=filename,
20
+ cache_dir = "."
21
+ )
22
+ subprocess.run(f"unzip {f}".split())
23
+
24
  def run_aim():
25
  cmd = f"aim up --host {HOST} --port {PORT}".split()
26
  subprocess.Popen(cmd)
27
 
28
+ html = f"""
29
+ <iframe
30
+ src="http://{HOST}:{PORT}"
31
+ ">
32
+ </iframe>
33
+ """
34
 
35
+ """
36
+
37
+ style="
38
+ position: fixed;
39
+ top: 0px;
40
+ bottom: 0px;
41
+ right: 0px;
42
+ width: 100%;
43
+ border: none;
44
+ margin: 0;
45
+ padding: 0;
46
+ overflow: hidden;
47
+ z-index: 999999;
48
+ height: 100%;
49
+ """
50
+
51
+ def run():
52
+ print("Starting server....")
53
+
54
+ def main():
55
+ download_logs()
56
  run_aim()
57
+ time.sleep(5)
58
  demo = gr.Interface(
59
  fn=run,
60
  inputs=[],
61
+ outputs=gr.HTML(html),
62
  )
63
+
64
  demo.launch()
65
+
66
+ if __name__ == "__main__":
67
+ main()
68