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

Upload web-ui.py

Browse files
Files changed (1) hide show
  1. web-ui.py +14 -14
web-ui.py CHANGED
@@ -12,6 +12,7 @@ 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()
@@ -174,21 +175,20 @@ with gr.Blocks() as demo:
174
  )
175
 
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)
 
 
 
 
 
12
  from insightface.utils import face_align
13
  from pyngrok import ngrok
14
  import threading
15
+ import time
16
 
17
  # Argument parser for command line options
18
  parser = argparse.ArgumentParser()
 
175
  )
176
 
177
  def start_ngrok():
178
+ # Set the correct port here. By default, Gradio uses 7860, but it might be different in your setup
179
+ gradio_port = 7860
180
+ ngrok.set_auth_token(args.ngrok_token)
181
+ public_url = ngrok.connect(gradio_port)
182
+ print(f"Public URL: {public_url}")
 
 
 
 
183
 
184
 
185
  if __name__ == "__main__":
186
+ # Launch the Gradio app in a separate thread
187
+ threading.Thread(target=lambda: demo.launch(share=args.share, inbrowser=True)).start()
 
188
 
189
+ # Give Gradio a few seconds to start up
190
+ time.sleep(5)
191
+
192
+ # Start ngrok
193
+ if args.ngrok_token:
194
+ start_ngrok()