{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Gradio 简介" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://0.0.0.0:4099\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import gradio as gr\n", "import plotly.express as px\n", "import pandas as pd\n", "def plotly_plot():\n", " # prepare some data\n", " x = [\"Math\", \"Business\", \"Statistics\", \"IT\", \"Commerce\"]\n", " y = [68, 73, 82, 74, 85]\n", " data = pd.DataFrame()\n", " data['Subject'] = x\n", " data['Score'] = y\n", " # create a new plot\n", " p = px.bar(data, x='Subject', y='Score')\n", "\n", " return p\n", "\n", "# show the results\n", "outputs = gr.Plot()\n", "\n", "demo = gr.Interface(fn=plotly_plot, inputs=None, outputs=outputs)\n", "\n", "# demo.launch()\n", "demo.launch(server_name=\"0.0.0.0\", server_port=4099, share=False, inbrowser=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }