{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Gradio InceptionNet v3 Demo.ipynb","version":"0.3.2","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"D_-55XdJy-Ml","colab_type":"text"},"cell_type":"markdown","source":["<img src=\"https://gradio.app/static/landing/img/logo_inline.png\" width=\"200px\">"]},{"metadata":{"id":"mDmSzM9NyosO","colab_type":"text"},"cell_type":"markdown","source":["Here's a short example notebook that demonstrates how to use the `gradio` python package. \n","\n","We will build a **visual interface** for InceptionNet, a state-of-the-art image classifier."]},{"metadata":{"id":"5QEZxZWWyTKi","colab_type":"text"},"cell_type":"markdown","source":["## Install the `gradio` python package and import it"]},{"metadata":{"id":"dGYdHy3eEIpL","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":123},"outputId":"82b24bee-e3d0-4d9d-bc72-7bdb389bbef8","executionInfo":{"status":"ok","timestamp":1556659546945,"user_tz":420,"elapsed":8052,"user":{"displayName":"Abubakar Abid","photoUrl":"https://lh5.googleusercontent.com/-4vHzlZuEn0I/AAAAAAAAAAI/AAAAAAAAGvk/UZwVjzGpazA/s64/photo.jpg","userId":"07393637958639896202"}}},"cell_type":"code","source":["!pip install gradio -q"],"execution_count":1,"outputs":[{"output_type":"stream","text":["\u001b[K    100% |████████████████████████████████| 1.9MB 13.6MB/s \n","\u001b[K    100% |████████████████████████████████| 194kB 30.2MB/s \n","\u001b[K    100% |████████████████████████████████| 61kB 22.9MB/s \n","\u001b[K    100% |████████████████████████████████| 2.3MB 10.3MB/s \n","\u001b[K    100% |████████████████████████████████| 768kB 24.7MB/s \n","\u001b[K    100% |████████████████████████████████| 102kB 28.8MB/s \n","\u001b[?25h"],"name":"stdout"}]},{"metadata":{"id":"hA6BTuNtELa9","colab_type":"code","colab":{}},"cell_type":"code","source":["import tensorflow as tf\n","import gradio"],"execution_count":0,"outputs":[]},{"metadata":{"id":"UThilKiayYz7","colab_type":"text"},"cell_type":"markdown","source":["## Load (or train) your own model"]},{"metadata":{"id":"Tz7p6MOEEOA9","colab_type":"code","outputId":"4f3499d1-d832-45bf-9082-e83357e38291","executionInfo":{"status":"ok","timestamp":1556659562482,"user_tz":420,"elapsed":23487,"user":{"displayName":"Abubakar Abid","photoUrl":"https://lh5.googleusercontent.com/-4vHzlZuEn0I/AAAAAAAAAAI/AAAAAAAAGvk/UZwVjzGpazA/s64/photo.jpg","userId":"07393637958639896202"}},"colab":{"base_uri":"https://localhost:8080/","height":125}},"cell_type":"code","source":["model = tf.keras.applications.inception_v3.InceptionV3();"],"execution_count":3,"outputs":[{"output_type":"stream","text":["WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n","Instructions for updating:\n","Colocations handled automatically by placer.\n","Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels.h5\n","96116736/96112376 [==============================] - 3s 0us/step\n"],"name":"stdout"}]},{"metadata":{"id":"YohC2oGEyesA","colab_type":"text"},"cell_type":"markdown","source":["## Define the input and output interfaces"]},{"metadata":{"id":"X_izWp0WEUCd","colab_type":"code","colab":{}},"cell_type":"code","source":["inp = gradio.inputs.ImageUpload(shape=(299, 299, 3))\n","out = gradio.outputs.Label(label_names='imagenet1000', max_label_length=8)\n","\n","io = gradio.Interface(inputs=inp, \n","                      outputs=out,\n","                      model=model, \n","                      model_type='keras')"],"execution_count":0,"outputs":[]},{"metadata":{"id":"eEAFNJhKyje6","colab_type":"text"},"cell_type":"markdown","source":["## Launch the Interfaces"]},{"metadata":{"id":"jv72dJ79XymV","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":609},"outputId":"9e963fe2-105c-4e6f-b065-d19021a67ef3","executionInfo":{"status":"ok","timestamp":1556659573601,"user_tz":420,"elapsed":34590,"user":{"displayName":"Abubakar Abid","photoUrl":"https://lh5.googleusercontent.com/-4vHzlZuEn0I/AAAAAAAAAAI/AAAAAAAAGvk/UZwVjzGpazA/s64/photo.jpg","userId":"07393637958639896202"}}},"cell_type":"code","source":["io.launch();"],"execution_count":5,"outputs":[{"output_type":"stream","text":["\n","\n","Validation passed successfully!\n","NOTE: Gradio is in beta stage, please report all bugs to: gradio.app@gmail.com\n","Model available publicly at: https://43258.gradio.app\n"],"name":"stdout"},{"output_type":"display_data","data":{"text/html":["\n","        <iframe\n","            width=\"1000\"\n","            height=\"500\"\n","            src=\"https://43258.gradio.app\"\n","            frameborder=\"0\"\n","            allowfullscreen\n","        ></iframe>\n","        "],"text/plain":["<IPython.lib.display.IFrame at 0x7fee7bd70160>"]},"metadata":{"tags":[]}}]},{"metadata":{"id":"c4e2UiXa1ckn","colab_type":"text"},"cell_type":"markdown","source":["**And that's it!**"]},{"metadata":{"id":"DCBBBnX3zTyl","colab_type":"text"},"cell_type":"markdown","source":["## What's next?"]},{"metadata":{"id":"4u-QXapJzko7","colab_type":"text"},"cell_type":"markdown","source":["Check out **www.gradio.app** for more examples and documentation. \n","\n","For updates on the `gradio` package (and a sneak peek of beta features), join the [**mailing list**](https://gradio.app/contact.html).\n","\n","And if you have any suggestions, you can reach us at **[gradio.app@gmail.com](mailto:gradio.app@gmail.com)** (and please do!)"]}]}