Commit
·
bf5edb4
1
Parent(s):
5d3a553
Upload web-ui.py
Browse files
web-ui.py
CHANGED
@@ -174,23 +174,17 @@ with gr.Blocks() as demo:
|
|
174 |
outputs=[output_gallery, output_text, display_seed],
|
175 |
)
|
176 |
|
177 |
-
def start_gradio():
|
178 |
-
demo.launch(share=args.share, inbrowser=True)
|
179 |
-
|
180 |
def start_ngrok():
|
181 |
-
#
|
182 |
-
gradio_port = 7860
|
183 |
ngrok.set_auth_token(args.ngrok_token)
|
184 |
-
public_url = ngrok.connect(
|
185 |
-
print(f"
|
186 |
-
|
187 |
-
if __name__ == "__main__":
|
188 |
-
# Launch the Gradio app in a separate thread
|
189 |
-
threading.Thread(target=start_gradio).start()
|
190 |
|
191 |
-
|
192 |
-
time.sleep(15) # Adjust the sleep time if necessary
|
193 |
-
|
194 |
-
# Start ngrok
|
195 |
if args.ngrok_token:
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
174 |
outputs=[output_gallery, output_text, display_seed],
|
175 |
)
|
176 |
|
|
|
|
|
|
|
177 |
def start_ngrok():
|
178 |
+
time.sleep(10) # Delay for 10 seconds to ensure Gradio starts first
|
|
|
179 |
ngrok.set_auth_token(args.ngrok_token)
|
180 |
+
public_url = ngrok.connect(port=7860) # Adjust to your Gradio app's port
|
181 |
+
print(f"ngrok tunnel started at {public_url}")
|
|
|
|
|
|
|
|
|
182 |
|
183 |
+
if __name__ == "__main__":
|
|
|
|
|
|
|
184 |
if args.ngrok_token:
|
185 |
+
# Start ngrok in a daemon thread with a delay
|
186 |
+
ngrok_thread = threading.Thread(target=start_ngrok, daemon=True)
|
187 |
+
ngrok_thread.start()
|
188 |
+
|
189 |
+
# Launch the Gradio app
|
190 |
+
demo.launch(share=args.share, inbrowser=True)
|