freddyaboulton HF Staff commited on
Commit
172274b
·
verified ·
1 Parent(s): 3980f18

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +32 -4
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@f49b8da1c062dbd81acb8e7fdcdc9a09a272d02f#subdirectory=client/python
2
- https://gradio-pypi-previews.s3.amazonaws.com/f49b8da1c062dbd81acb8e7fdcdc9a09a272d02f/gradio-5.35.0-py3-none-any.whl
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@6b2bcd097ae5ef999a7fb273ecf7c7e4c0eab305#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/6b2bcd097ae5ef999a7fb273ecf7c7e4c0eab305/gradio-5.35.0-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: function_values"]}, {"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 gradio as gr\n", "import random\n", "\n", "countries = [\n", " \"Algeria\", \"Argentina\", \"Australia\", \"Brazil\", \"Canada\", \"China\", \"Democratic Republic of the Congo\", \"Greenland (Denmark)\", \"India\", \"Kazakhstan\", \"Mexico\", \"Mongolia\", \"Peru\", \"Russia\", \"Saudi Arabia\", \"Sudan\", \"United States\"\n", "]\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " count = gr.Slider(1, 10, step=1, label=\"Country Count\")\n", " alpha_order = gr.Checkbox(True, label=\"Alphabetical Order\")\n", "\n", " gr.JSON(lambda count, alpha_order: countries[:count] if alpha_order else countries[-count:], inputs=[count, alpha_order])\n", " timer = gr.Timer(1)\n", " with gr.Row():\n", " gr.Textbox(lambda: random.choice(countries), label=\"Random Country\", every=timer)\n", " gr.Textbox(lambda count: \", \".join(random.sample(countries, count)), inputs=count, label=\"Random Countries\", every=timer)\n", " with gr.Row():\n", " gr.Button(\"Start\").click(lambda: gr.Timer(active=True), None, timer)\n", " gr.Button(\"Stop\").click(lambda: gr.Timer(active=False), None, timer)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: function_values"]}, {"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 gradio as gr\n", "import random\n", "\n", "countries = [\n", " \"Algeria\",\n", " \"Argentina\",\n", " \"Australia\",\n", " \"Brazil\",\n", " \"Canada\",\n", " \"China\",\n", " \"Democratic Republic of the Congo\",\n", " \"Greenland (Denmark)\",\n", " \"India\",\n", " \"Kazakhstan\",\n", " \"Mexico\",\n", " \"Mongolia\",\n", " \"Peru\",\n", " \"Russia\",\n", " \"Saudi Arabia\",\n", " \"Sudan\",\n", " \"United States\",\n", "]\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Row():\n", " count = gr.Slider(1, 10, step=1, label=\"Country Count\")\n", " alpha_order = gr.Checkbox(True, label=\"Alphabetical Order\")\n", "\n", " gr.JSON(\n", " lambda count, alpha_order: countries[:count]\n", " if alpha_order\n", " else countries[-count:],\n", " inputs=[count, alpha_order],\n", " )\n", " timer = gr.Timer(1)\n", " with gr.Row():\n", " gr.Textbox(\n", " lambda: random.choice(countries), label=\"Random Country\", every=timer\n", " )\n", " gr.Textbox(\n", " lambda count: \", \".join(random.sample(countries, count)),\n", " inputs=count,\n", " label=\"Random Countries\",\n", " every=timer,\n", " )\n", " with gr.Row():\n", " gr.Button(\"Start\").click(lambda: gr.Timer(active=True), None, timer)\n", " gr.Button(\"Stop\").click(lambda: gr.Timer(active=False), None, timer)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -2,7 +2,23 @@ import gradio as gr
2
  import random
3
 
4
  countries = [
5
- "Algeria", "Argentina", "Australia", "Brazil", "Canada", "China", "Democratic Republic of the Congo", "Greenland (Denmark)", "India", "Kazakhstan", "Mexico", "Mongolia", "Peru", "Russia", "Saudi Arabia", "Sudan", "United States"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  ]
7
 
8
  with gr.Blocks() as demo:
@@ -10,11 +26,23 @@ with gr.Blocks() as demo:
10
  count = gr.Slider(1, 10, step=1, label="Country Count")
11
  alpha_order = gr.Checkbox(True, label="Alphabetical Order")
12
 
13
- gr.JSON(lambda count, alpha_order: countries[:count] if alpha_order else countries[-count:], inputs=[count, alpha_order])
 
 
 
 
 
14
  timer = gr.Timer(1)
15
  with gr.Row():
16
- gr.Textbox(lambda: random.choice(countries), label="Random Country", every=timer)
17
- gr.Textbox(lambda count: ", ".join(random.sample(countries, count)), inputs=count, label="Random Countries", every=timer)
 
 
 
 
 
 
 
18
  with gr.Row():
19
  gr.Button("Start").click(lambda: gr.Timer(active=True), None, timer)
20
  gr.Button("Stop").click(lambda: gr.Timer(active=False), None, timer)
 
2
  import random
3
 
4
  countries = [
5
+ "Algeria",
6
+ "Argentina",
7
+ "Australia",
8
+ "Brazil",
9
+ "Canada",
10
+ "China",
11
+ "Democratic Republic of the Congo",
12
+ "Greenland (Denmark)",
13
+ "India",
14
+ "Kazakhstan",
15
+ "Mexico",
16
+ "Mongolia",
17
+ "Peru",
18
+ "Russia",
19
+ "Saudi Arabia",
20
+ "Sudan",
21
+ "United States",
22
  ]
23
 
24
  with gr.Blocks() as demo:
 
26
  count = gr.Slider(1, 10, step=1, label="Country Count")
27
  alpha_order = gr.Checkbox(True, label="Alphabetical Order")
28
 
29
+ gr.JSON(
30
+ lambda count, alpha_order: countries[:count]
31
+ if alpha_order
32
+ else countries[-count:],
33
+ inputs=[count, alpha_order],
34
+ )
35
  timer = gr.Timer(1)
36
  with gr.Row():
37
+ gr.Textbox(
38
+ lambda: random.choice(countries), label="Random Country", every=timer
39
+ )
40
+ gr.Textbox(
41
+ lambda count: ", ".join(random.sample(countries, count)),
42
+ inputs=count,
43
+ label="Random Countries",
44
+ every=timer,
45
+ )
46
  with gr.Row():
47
  gr.Button("Start").click(lambda: gr.Timer(active=True), None, timer)
48
  gr.Button("Stop").click(lambda: gr.Timer(active=False), None, timer)