gradio/examples/Simple Sentence Capitalization (Textbox Input and Output).ipynb

112 lines
3.7 KiB
Plaintext
Raw Normal View History

2019-02-23 12:25:31 +08:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting gradio\n",
" Downloading https://files.pythonhosted.org/packages/3a/ca/62d769859ce82ff93bc1f8c01002a912e0e55ddaf702a880a9f30aaf9303/gradio-0.1.7-py3-none-any.whl (725kB)\n",
"Requirement already satisfied: psutil in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (5.4.7)\n",
"Requirement already satisfied: requests in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (2.19.1)\n",
"Requirement already satisfied: Pillow in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (5.2.0)\n",
"Requirement already satisfied: nest-asyncio in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (0.9.10)\n",
"Requirement already satisfied: websockets in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (7.0)\n",
"Requirement already satisfied: numpy in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (1.15.1)\n",
"Requirement already satisfied: beautifulsoup4 in c:\\users\\islam\\anaconda3\\lib\\site-packages (from gradio) (4.6.3)\n",
"Requirement already satisfied: urllib3<1.24,>=1.21.1 in c:\\users\\islam\\anaconda3\\lib\\site-packages (from requests->gradio) (1.23)\n",
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\islam\\anaconda3\\lib\\site-packages (from requests->gradio) (2018.8.24)\n",
"Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\\users\\islam\\anaconda3\\lib\\site-packages (from requests->gradio) (3.0.4)\n",
"Requirement already satisfied: idna<2.8,>=2.5 in c:\\users\\islam\\anaconda3\\lib\\site-packages (from requests->gradio) (2.7)\n",
"Installing collected packages: gradio\n",
"Successfully installed gradio-0.1.7\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"You are using pip version 18.1, however version 19.0.2 is available.\n",
"You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
]
}
],
"source": [
"!pip install gradio"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import gradio"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"def capitalize_each_word(s):\n",
" return \" \".join(w.capitalize() for w in s.split())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"iface = gradio.Interface(input=\"textbox\", output=\"textbox\", model=capitalize_each_word, model_type='func')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NOTE: Gradio is in beta stage, please report all bugs to: a12d@stanford.edu\n",
"Model available locally at: http://localhost:7860/interface.html\n",
"Model available publicly for 8 hours at: http://aed68955.ngrok.io/interface.html\n"
]
}
],
"source": [
"iface.launch()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}