added ability to build interface from command line

This commit is contained in:
Abubakar Abid 2019-03-01 19:21:56 -08:00
parent b2817ec4b0
commit 1b9f292718
2 changed files with 18 additions and 0 deletions

16
build-interface.py Normal file
View File

@ -0,0 +1,16 @@
from argparse import ArgumentParser
import gradio
parser = ArgumentParser(description='Arguments for Building Interface')
parser.add_argument('-i', '--inputs', type=str, help="name of input interface")
parser.add_argument('-o', '--outputs', type=str, help="name of output interface")
args = parser.parse_args()
def launch_interface(args):
io = gradio.Interface(inputs=args.inputs, outputs=args.outputs, model=lambda x:x, model_type='function')
io.launch()
if __name__ == "__main__":
launch_interface(args)

View File

@ -142,6 +142,7 @@ class Interface:
else:
if self.verbose:
print("To create a public link, set `share=True` in the argument to `launch()`")
site_ngrok_url = None
# Keep the server running in the background.
asyncio.get_event_loop().run_until_complete(start_server)
@ -151,3 +152,4 @@ class Interface:
pass
webbrowser.open(path_to_server + networking.TEMPLATE_TEMP) # Open a browser tab with the interface.
return path_to_server + networking.TEMPLATE_TEMP, site_ngrok_url