Skip to content

Commit

Permalink
fix(api): open web browser when launching Windows bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Apr 10, 2023
1 parent 8beb099 commit fea9185
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions api/entry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import multiprocessing
import os
import webbrowser

def script_method(fn, _rcb=None):
return fn
Expand All @@ -10,22 +12,25 @@ def script(obj, optimize=True, _frames_up=0, _rcb=None):
torch.jit.script_method = script_method
torch.jit.script = script

import multiprocessing

if __name__ == '__main__':
multiprocessing.freeze_support()
try:
from onnx_web.convert.__main__ import main as convert
print("converting models")
print("converting models to ONNX")
convert()

from onnx_web.main import main
app, pool = main()
print("starting workers")
print("starting image workers")
pool.start()
print("starting flask")

print("starting API server")
app.run("0.0.0.0", 5000, debug=False)
input("press the any key")

url = "http://127.0.0.1:5000"
webbrowser.open_new_tab(f"{url}?api={url}")

input("press enter to quit")
pool.join()
except Exception as e:
print(e)
Expand Down

0 comments on commit fea9185

Please sign in to comment.