MonsterMMORPG commited on
Commit
49b3a73
·
1 Parent(s): 8a76916

Upload web-ui.py

Browse files
Files changed (1) hide show
  1. web-ui.py +14 -6
web-ui.py CHANGED
@@ -11,6 +11,7 @@ import argparse
11
  import random
12
  from insightface.utils import face_align
13
  from pyngrok import ngrok
 
14
 
15
  # Argument parser for command line options
16
  parser = argparse.ArgumentParser()
@@ -175,12 +176,19 @@ with gr.Blocks() as demo:
175
  def start_ngrok():
176
  if args.ngrok_token:
177
  ngrok.set_auth_token(args.ngrok_token)
178
- url = ngrok.connect(port=7860) # You can choose your desired port
179
- print(f"ngrok tunnel started at {url}")
 
 
 
 
 
180
 
181
- if __name__ == "__main__":
182
- demo.launch(share=args.share, inbrowser=True)
183
 
184
- # Start ngrok after launching Gradio
185
  if args.ngrok_token:
186
- start_ngrok()
 
 
 
 
 
11
  import random
12
  from insightface.utils import face_align
13
  from pyngrok import ngrok
14
+ import threading
15
 
16
  # Argument parser for command line options
17
  parser = argparse.ArgumentParser()
 
176
  def start_ngrok():
177
  if args.ngrok_token:
178
  ngrok.set_auth_token(args.ngrok_token)
179
+ url = ngrok.connect(port=7860) # Adjust the port if necessary
180
+ print(f"ngrok tunnel started at {url}")
181
+
182
+ def delayed_ngrok_start():
183
+ import time
184
+ time.sleep(5) # Wait for 5 seconds before starting ngrok
185
+ start_ngrok()
186
 
 
 
187
 
188
+ if __name__ == "__main__":
189
  if args.ngrok_token:
190
+ # Start ngrok in a separate thread
191
+ threading.Thread(target=delayed_ngrok_start).start()
192
+
193
+ # Launch Gradio app
194
+ demo.launch(share=args.share, inbrowser=True)