{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install Gradio\n", "!pip install gradio" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Import Gradio\n", "import gradio as gr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Define the paint function\n", "def paint_canvas(image):\n", " # Simply return the image as is\n", " return image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create the Gradio interface\n", "iface = gr.Interface(\n", " fn=paint_canvas, # Function to call\n", " inputs=\"sketchpad\", # Input is a sketchpad\n", " outputs=\"image\", # Output is an image\n", " live=True, # Real-time updates\n", " title=\"Paint Canvas\", # Title of the app\n", " description=\"Draw something on the canvas and see it displayed below!\", # Description\n", " theme=\"Felguk/Felguk_theme\" # Apply the xkcd comic-style theme\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Launch the interface\n", "iface.launch(inline=True) # Embed the interface in the notebook" ] } ], "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.9.0" } }, "nbformat": 4, "nbformat_minor": 5 }