freddyaboulton HF staff commited on
Commit
2d5fe22
1 Parent(s): 724205e

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. requirements.txt +3 -2
  3. run.ipynb +1 -1
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 4.44.1
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 5.0.0
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@a15381b23d3f6b59180e83a94a5279feccbf79a2#subdirectory=client/python
2
- https://gradio-pypi-previews.s3.amazonaws.com/a15381b23d3f6b59180e83a94a5279feccbf79a2/gradio-4.44.1-py3-none-any.whl
 
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@bbf9ba7e997022960c621f72baa891185bd03732#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/bbf9ba7e997022960c621f72baa891185bd03732/gradio-5.0.0-py3-none-any.whl
3
+ pandas
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: scatter_plot_demo"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import pandas as pd\n", "from random import randint, random\n", "import gradio as gr\n", "\n", "\n", "temp_sensor_data = pd.DataFrame(\n", " {\n", " \"time\": pd.date_range(\"2021-01-01\", end=\"2021-01-05\", periods=200),\n", " \"temperature\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"humidity\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"location\": [\"indoor\", \"outdoor\"] * 100,\n", " }\n", ")\n", "\n", "food_rating_data = pd.DataFrame(\n", " {\n", " \"cuisine\": [[\"Italian\", \"Mexican\", \"Chinese\"][i % 3] for i in range(100)],\n", " \"rating\": [random() * 4 + 0.5 * (i % 3) for i in range(100)],\n", " \"price\": [randint(10, 50) + 4 * (i % 3) for i in range(100)],\n", " \"wait\": [random() for i in range(100)],\n", " }\n", ")\n", "\n", "with gr.Blocks() as scatter_plots:\n", " with gr.Row():\n", " start = gr.DateTime(\"2021-01-01 00:00:00\", label=\"Start\")\n", " end = gr.DateTime(\"2021-01-05 00:00:00\", label=\"End\")\n", " apply_btn = gr.Button(\"Apply\", scale=0)\n", " with gr.Row():\n", " group_by = gr.Radio([\"None\", \"30m\", \"1h\", \"4h\", \"1d\"], value=\"None\", label=\"Group by\")\n", " aggregate = gr.Radio([\"sum\", \"mean\", \"median\", \"min\", \"max\"], value=\"sum\", label=\"Aggregation\")\n", "\n", " temp_by_time = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " )\n", " temp_by_time_location = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " color=\"location\",\n", " )\n", "\n", " time_graphs = [temp_by_time, temp_by_time_location]\n", " group_by.change(\n", " lambda group: [gr.ScatterPlot(x_bin=None if group == \"None\" else group)] * len(time_graphs),\n", " group_by,\n", " time_graphs\n", " )\n", " aggregate.change(\n", " lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),\n", " aggregate,\n", " time_graphs\n", " )\n", "\n", " price_by_cuisine = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"cuisine\",\n", " y=\"price\",\n", " )\n", " with gr.Row():\n", " price_by_rating = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"wait\",\n", " show_actions_button=True,\n", " )\n", " price_by_rating_color = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"cuisine\",\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " scatter_plots.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: scatter_plot_demo"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio pandas "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import pandas as pd\n", "from random import randint, random\n", "import gradio as gr\n", "\n", "\n", "temp_sensor_data = pd.DataFrame(\n", " {\n", " \"time\": pd.date_range(\"2021-01-01\", end=\"2021-01-05\", periods=200),\n", " \"temperature\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"humidity\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"location\": [\"indoor\", \"outdoor\"] * 100,\n", " }\n", ")\n", "\n", "food_rating_data = pd.DataFrame(\n", " {\n", " \"cuisine\": [[\"Italian\", \"Mexican\", \"Chinese\"][i % 3] for i in range(100)],\n", " \"rating\": [random() * 4 + 0.5 * (i % 3) for i in range(100)],\n", " \"price\": [randint(10, 50) + 4 * (i % 3) for i in range(100)],\n", " \"wait\": [random() for i in range(100)],\n", " }\n", ")\n", "\n", "with gr.Blocks() as scatter_plots:\n", " with gr.Row():\n", " start = gr.DateTime(\"2021-01-01 00:00:00\", label=\"Start\")\n", " end = gr.DateTime(\"2021-01-05 00:00:00\", label=\"End\")\n", " apply_btn = gr.Button(\"Apply\", scale=0)\n", " with gr.Row():\n", " group_by = gr.Radio([\"None\", \"30m\", \"1h\", \"4h\", \"1d\"], value=\"None\", label=\"Group by\")\n", " aggregate = gr.Radio([\"sum\", \"mean\", \"median\", \"min\", \"max\"], value=\"sum\", label=\"Aggregation\")\n", "\n", " temp_by_time = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " )\n", " temp_by_time_location = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " color=\"location\",\n", " )\n", "\n", " time_graphs = [temp_by_time, temp_by_time_location]\n", " group_by.change(\n", " lambda group: [gr.ScatterPlot(x_bin=None if group == \"None\" else group)] * len(time_graphs),\n", " group_by,\n", " time_graphs\n", " )\n", " aggregate.change(\n", " lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),\n", " aggregate,\n", " time_graphs\n", " )\n", "\n", " price_by_cuisine = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"cuisine\",\n", " y=\"price\",\n", " )\n", " with gr.Row():\n", " price_by_rating = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"wait\",\n", " show_actions_button=True,\n", " )\n", " price_by_rating_color = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"cuisine\",\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " scatter_plots.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}