Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,7 +5,7 @@ emoji: 🔥
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
-
sdk_version:
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
|
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 6.0.0
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: line_plot"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio vega_datasets pandas"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from vega_datasets import data\n", "\n", "stocks = data.stocks()\n", "gapminder = data.gapminder()\n", "gapminder = gapminder.loc[\n", " gapminder.country.isin([\"Argentina\", \"Australia\", \"Afghanistan\"])\n", "]\n", "climate = data.climate()\n", "seattle_weather = data.seattle_weather()\n", "\n", "## Or generate your own fake data, here's an example for stocks:\n", "#\n", "# import pandas as pd\n", "# import random\n", "#\n", "# stocks = pd.DataFrame(\n", "# {\n", "# \"symbol\": [\n", "# random.choice(\n", "# [\n", "# \"MSFT\",\n", "# \"AAPL\",\n", "# \"AMZN\",\n", "# \"IBM\",\n", "# \"GOOG\",\n", "# ]\n", "# )\n", "# for _ in range(120)\n", "# ],\n", "# \"date\": [\n", "# pd.Timestamp(year=2000 + i, month=j, day=1)\n", "# for i in range(10)\n", "# for j in range(1, 13)\n", "# ],\n", "# \"price\": [random.randint(10, 200) for _ in range(120)],\n", "# }\n", "# )\n", "\n", "def line_plot_fn(dataset):\n", " if dataset == \"stocks\":\n", " return gr.LinePlot(\n", " stocks,\n", " x=\"date\",\n", " y=\"price\",\n", " color=\"symbol\",\n", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: line_plot"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio vega_datasets pandas"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from vega_datasets import data\n", "\n", "stocks = data.stocks()\n", "gapminder = data.gapminder()\n", "gapminder = gapminder.loc[\n", " gapminder.country.isin([\"Argentina\", \"Australia\", \"Afghanistan\"])\n", "]\n", "climate = data.climate()\n", "seattle_weather = data.seattle_weather()\n", "\n", "## Or generate your own fake data, here's an example for stocks:\n", "#\n", "# import pandas as pd\n", "# import random\n", "#\n", "# stocks = pd.DataFrame(\n", "# {\n", "# \"symbol\": [\n", "# random.choice(\n", "# [\n", "# \"MSFT\",\n", "# \"AAPL\",\n", "# \"AMZN\",\n", "# \"IBM\",\n", "# \"GOOG\",\n", "# ]\n", "# )\n", "# for _ in range(120)\n", "# ],\n", "# \"date\": [\n", "# pd.Timestamp(year=2000 + i, month=j, day=1)\n", "# for i in range(10)\n", "# for j in range(1, 13)\n", "# ],\n", "# \"price\": [random.randint(10, 200) for _ in range(120)],\n", "# }\n", "# )\n", "\n", "def line_plot_fn(dataset):\n", " if dataset == \"stocks\":\n", " return gr.LinePlot(\n", " stocks,\n", " x=\"date\",\n", " y=\"price\",\n", " color=\"symbol\",\n", " title=\"Stock Prices\",\n", " tooltip=[\"date\", \"price\", \"symbol\"],\n", " height=300,\n", " )\n", " elif dataset == \"climate\":\n", " return gr.LinePlot(\n", " climate,\n", " x=\"DATE\",\n", " y=\"HLY-TEMP-NORMAL\",\n", " y_lim=[250, 500],\n", " title=\"Climate\",\n", " tooltip=[\"DATE\", \"HLY-TEMP-NORMAL\"],\n", " height=300,\n", " )\n", " elif dataset == \"seattle_weather\":\n", " return gr.LinePlot(\n", " seattle_weather,\n", " x=\"date\",\n", " y=\"temp_min\",\n", " tooltip=[\"weather\", \"date\"],\n", " title=\"Seattle Weather\",\n", " height=300,\n", " )\n", " elif dataset == \"gapminder\":\n", " return gr.LinePlot(\n", " gapminder,\n", " x=\"year\",\n", " y=\"life_expect\",\n", " color=\"country\",\n", " title=\"Life expectancy for countries\",\n", " x_lim=[1950, 2010],\n", " tooltip=[\"country\", \"life_expect\"],\n", " height=300,\n", " )\n", "\n", "with gr.Blocks() as line_plot:\n", " with gr.Row():\n", " with gr.Column():\n", " dataset = gr.Dropdown(\n", " choices=[\"stocks\", \"climate\", \"seattle_weather\", \"gapminder\"],\n", " value=\"stocks\",\n", " )\n", " with gr.Column():\n", " plot = gr.LinePlot()\n", " dataset.change(line_plot_fn, inputs=dataset, outputs=plot)\n", " line_plot.load(fn=line_plot_fn, inputs=dataset, outputs=plot)\n", "\n", "if __name__ == \"__main__\":\n", " line_plot.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -44,11 +44,9 @@ def line_plot_fn(dataset):
|
|
| 44 |
x="date",
|
| 45 |
y="price",
|
| 46 |
color="symbol",
|
| 47 |
-
color_legend_position="bottom",
|
| 48 |
title="Stock Prices",
|
| 49 |
tooltip=["date", "price", "symbol"],
|
| 50 |
height=300,
|
| 51 |
-
width=500,
|
| 52 |
)
|
| 53 |
elif dataset == "climate":
|
| 54 |
return gr.LinePlot(
|
|
@@ -59,7 +57,6 @@ def line_plot_fn(dataset):
|
|
| 59 |
title="Climate",
|
| 60 |
tooltip=["DATE", "HLY-TEMP-NORMAL"],
|
| 61 |
height=300,
|
| 62 |
-
width=500,
|
| 63 |
)
|
| 64 |
elif dataset == "seattle_weather":
|
| 65 |
return gr.LinePlot(
|
|
@@ -67,10 +64,8 @@ def line_plot_fn(dataset):
|
|
| 67 |
x="date",
|
| 68 |
y="temp_min",
|
| 69 |
tooltip=["weather", "date"],
|
| 70 |
-
overlay_point=True,
|
| 71 |
title="Seattle Weather",
|
| 72 |
height=300,
|
| 73 |
-
width=500,
|
| 74 |
)
|
| 75 |
elif dataset == "gapminder":
|
| 76 |
return gr.LinePlot(
|
|
@@ -79,12 +74,9 @@ def line_plot_fn(dataset):
|
|
| 79 |
y="life_expect",
|
| 80 |
color="country",
|
| 81 |
title="Life expectancy for countries",
|
| 82 |
-
stroke_dash="cluster",
|
| 83 |
x_lim=[1950, 2010],
|
| 84 |
tooltip=["country", "life_expect"],
|
| 85 |
-
stroke_dash_legend_title="Country Cluster",
|
| 86 |
height=300,
|
| 87 |
-
width=500,
|
| 88 |
)
|
| 89 |
|
| 90 |
with gr.Blocks() as line_plot:
|
|
|
|
| 44 |
x="date",
|
| 45 |
y="price",
|
| 46 |
color="symbol",
|
|
|
|
| 47 |
title="Stock Prices",
|
| 48 |
tooltip=["date", "price", "symbol"],
|
| 49 |
height=300,
|
|
|
|
| 50 |
)
|
| 51 |
elif dataset == "climate":
|
| 52 |
return gr.LinePlot(
|
|
|
|
| 57 |
title="Climate",
|
| 58 |
tooltip=["DATE", "HLY-TEMP-NORMAL"],
|
| 59 |
height=300,
|
|
|
|
| 60 |
)
|
| 61 |
elif dataset == "seattle_weather":
|
| 62 |
return gr.LinePlot(
|
|
|
|
| 64 |
x="date",
|
| 65 |
y="temp_min",
|
| 66 |
tooltip=["weather", "date"],
|
|
|
|
| 67 |
title="Seattle Weather",
|
| 68 |
height=300,
|
|
|
|
| 69 |
)
|
| 70 |
elif dataset == "gapminder":
|
| 71 |
return gr.LinePlot(
|
|
|
|
| 74 |
y="life_expect",
|
| 75 |
color="country",
|
| 76 |
title="Life expectancy for countries",
|
|
|
|
| 77 |
x_lim=[1950, 2010],
|
| 78 |
tooltip=["country", "life_expect"],
|
|
|
|
| 79 |
height=300,
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
with gr.Blocks() as line_plot:
|