mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
commit
65c4924f9e
@ -512,7 +512,9 @@ class Interface:
|
||||
print("PASSED")
|
||||
continue
|
||||
|
||||
def launch(self, inline=None, inbrowser=None, share=False, debug=False, auth=None, auth_message=None, private_endpoint=None, prevent_thread_lock=False):
|
||||
def launch(self, inline=None, inbrowser=None, share=False, debug=False,
|
||||
auth=None, auth_message=None, private_endpoint=None,
|
||||
prevent_thread_lock=False, show_error=True):
|
||||
"""
|
||||
Launches the webserver that serves the UI for the interface.
|
||||
Parameters:
|
||||
@ -526,6 +528,7 @@ class Interface:
|
||||
app (flask.Flask): Flask app object
|
||||
path_to_local_server (str): Locally accessible link
|
||||
share_url (str): Publicly accessible link (if share=True)
|
||||
show_error (bool): show prediction errors in console
|
||||
"""
|
||||
# Alert user if a more recent version of the library exists
|
||||
utils.version_check()
|
||||
@ -550,6 +553,7 @@ class Interface:
|
||||
self.server_port = server_port
|
||||
self.status = "RUNNING"
|
||||
self.server = app
|
||||
self.show_error = show_error
|
||||
|
||||
# Count number of launches
|
||||
launch_counter()
|
||||
|
@ -175,7 +175,15 @@ def enable_sharing(path):
|
||||
@login_check
|
||||
def predict():
|
||||
raw_input = request.json["data"]
|
||||
prediction, durations = app.interface.process(raw_input)
|
||||
# If in debug mode, capture any errors made and pipe to front end
|
||||
if app.interface.show_error:
|
||||
try:
|
||||
prediction, durations = app.interface.process(raw_input)
|
||||
except BaseException as error:
|
||||
traceback.print_exc()
|
||||
return jsonify({"error": traceback.format_exc()}), 500
|
||||
else:
|
||||
prediction, durations = app.interface.process(raw_input)
|
||||
avg_durations = []
|
||||
for i, duration in enumerate(durations):
|
||||
app.interface.predict_durations[i][0] += duration
|
||||
|
Loading…
Reference in New Issue
Block a user