diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..51a124a81e82ec225cd95732511f956e3e00c731 Binary files /dev/null and b/.DS_Store differ diff --git a/GUI_Tutorial.ipynb b/GUI_Tutorial.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..64bfa4260a98304a6f36932ab3cd8f2565beb166 --- /dev/null +++ b/GUI_Tutorial.ipynb @@ -0,0 +1,214 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "7227f3fa", + "metadata": {}, + "source": [ + "## Gradio: How you can build a GUI within a Jupyter Notebook\n", + "\n", + "#### By Team JACT" + ] + }, + { + "cell_type": "markdown", + "id": "ba81c68d", + "metadata": {}, + "source": [ + "## Getting Started\n", + "\n", + "First, the gradio library must be installed on your computer. It requires Python 3.7 or later. If you have not done so already, please check your version of Python and run the following line of code:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "cdfdbb3e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Python 3.9.7\r\n" + ] + } + ], + "source": [ + "!python --version" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "8f5edb3b", + "metadata": {}, + "outputs": [], + "source": [ + "#!pip install gradio" + ] + }, + { + "cell_type": "markdown", + "id": "f76c9232", + "metadata": {}, + "source": [ + "Next, import the library as follows:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "227461d8", + "metadata": { + "scrolled": false + }, + "outputs": [], + "source": [ + "import gradio as gr" + ] + }, + { + "cell_type": "markdown", + "id": "c3d4eb50", + "metadata": {}, + "source": [ + "Gradio can be used with a wide range of media-text, pictures, video, and sound. It is most useful for demonstrating machine learning algorithms.\n", + "\n", + "To get a feel for how it works, run the cell below this one. An interface will automatically pop up within the Jupyter Notebook. You can type your input directing into the interface." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "92c83d6b", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Running on local URL: http://127.0.0.1:7861/\n", + "\n", + "To create a public link, set `share=True` in `launch()`.\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + " <iframe\n", + " width=\"900\"\n", + " height=\"500\"\n", + " src=\"http://127.0.0.1:7861/\"\n", + " frameborder=\"0\"\n", + " allowfullscreen\n", + " \n", + " ></iframe>\n", + " " + ], + "text/plain": [ + "<IPython.lib.display.IFrame at 0x7f8998c2e2b0>" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "(<fastapi.applications.FastAPI at 0x7f8979fb7f40>,\n", + " 'http://127.0.0.1:7861/',\n", + " None)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def greet(name):\n", + " return \"Hello \" + name + \"!!\"\n", + "\n", + "iface = gr.Interface(fn=greet, inputs=\"text\", outputs=\"text\")\n", + "iface.launch()" + ] + }, + { + "cell_type": "markdown", + "id": "8469e7e7", + "metadata": {}, + "source": [ + "### The Interface\n", + "\n", + "The core interface has three parameters:\n", + " 1. fn: The function.\n", + " 2. inputs: The input component.\n", + " 3. outputs: The output component.\n", + " \n", + "With these components, you can quickly create and launch an interface." + ] + }, + { + "cell_type": "markdown", + "id": "94a5d6f2", + "metadata": {}, + "source": [ + "Gradio is compatible with machine l" + ] + }, + { + "cell_type": "markdown", + "id": "1196a4c1", + "metadata": {}, + "source": [ + "LEFT TO ANSWER:\n", + "\n", + "An overview of what data is are available in the data or tool\n", + " It can be used with image classification...\n", + "\n", + "An example question and visualization that that the data or tool can answer (this should be unique)\n", + "\n", + "How this data or tool could be used in some of the team projects (maybe not your own)\n", + "\n", + "Proper references to any resources used to build the tutorial" + ] + }, + { + "cell_type": "markdown", + "id": "500e9ab6", + "metadata": {}, + "source": [ + "Sources:\n", + "https://www.analyticsvidhya.com/blog/2021/04/create-interface-for-your-machine-learning-models-using-gradio-python-library/\n", + "\n", + "https://gradio.app/getting_started/\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}