gradio-pr-bot commited on
Commit
dabf0da
1 Parent(s): 9d0288c

Upload folder using huggingface_hub

Browse files
demos/calculator/run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: calculator"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('examples')\n", "!wget -q -O examples/log.csv https://github.com/gradio-app/gradio/raw/main/demo/calculator/examples/log.csv"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from foo import foo_fn\n", "\n", "if gr.NO_RELOAD:\n", " print(\"FOO\")\n", " import numpy as np\n", "\n", "\n", "\n", "def calculator(num1, operation, num2):\n", " print(\"foo_fn\", foo_fn())\n", " if operation == \"add\":\n", " return num1 + num2\n", " elif operation == \"subtract\":\n", " return num1 - num2\n", " elif operation == \"multiply\":\n", " return num1 * num2\n", " elif operation == \"divide\":\n", " if num2 == 0:\n", " raise gr.Error(\"Cannot divide by zero!\")\n", " return num1 / num2\n", "\n", "demo = gr.Interface(\n", " calculator,\n", " [\n", " \"number\", \n", " gr.Radio([\"add\", \"subtract\", \"multiply\", \"divide\"], label=\"OPeration@@\"),\n", " \"number\"\n", " ],\n", " \"number\",\n", " examples=[\n", " [45, \"add\", 30],\n", " [3.14, \"divide\", 2],\n", " [144, \"multiply\", 2.5],\n", " [0, \"subtract\", 1.2],\n", " ],\n", " title=\"Toy Calculator\",\n", " description=\"Here's a sample toy calculator. Allows you to calculate things like $2+2=4$\",\n", ")\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: calculator"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('examples')\n", "!wget -q -O examples/log.csv https://github.com/gradio-app/gradio/raw/main/demo/calculator/examples/log.csv"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "#from foo import BAR\n", "#\n", "def calculator(num1, operation, num2):\n", " if operation == \"add\":\n", " return num1 + num2\n", " elif operation == \"subtract\":\n", " return num1 - num2\n", " elif operation == \"multiply\":\n", " return num1 * num2\n", " elif operation == \"divide\":\n", " if num2 == 0:\n", " raise gr.Error(\"Cannot divide by zero!\")\n", " return num1 / num2\n", "\n", "demo = gr.Interface(\n", " calculator,\n", " [\n", " \"number\", \n", " gr.Radio([\"add\", \"subtract\", \"multiply\", \"divide\"]),\n", " \"number\"\n", " ],\n", " \"number\",\n", " examples=[\n", " [45, \"add\", 3],\n", " [3.14, \"divide\", 2],\n", " [144, \"multiply\", 2.5],\n", " [0, \"subtract\", 1.2],\n", " ],\n", " title=\"Toy Calculator\",\n", " description=\"Here's a sample toy calculator. Allows you to calculate things like $2+2=4$\",\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
demos/calculator/run.py CHANGED
@@ -1,14 +1,7 @@
1
  import gradio as gr
2
- from foo import foo_fn
3
-
4
- if gr.NO_RELOAD:
5
- print("FOO")
6
- import numpy as np
7
-
8
-
9
-
10
  def calculator(num1, operation, num2):
11
- print("foo_fn", foo_fn())
12
  if operation == "add":
13
  return num1 + num2
14
  elif operation == "subtract":
@@ -24,12 +17,12 @@ demo = gr.Interface(
24
  calculator,
25
  [
26
  "number",
27
- gr.Radio(["add", "subtract", "multiply", "divide"], label="OPeration@@"),
28
  "number"
29
  ],
30
  "number",
31
  examples=[
32
- [45, "add", 30],
33
  [3.14, "divide", 2],
34
  [144, "multiply", 2.5],
35
  [0, "subtract", 1.2],
 
1
  import gradio as gr
2
+ #from foo import BAR
3
+ #
 
 
 
 
 
 
4
  def calculator(num1, operation, num2):
 
5
  if operation == "add":
6
  return num1 + num2
7
  elif operation == "subtract":
 
17
  calculator,
18
  [
19
  "number",
20
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
21
  "number"
22
  ],
23
  "number",
24
  examples=[
25
+ [45, "add", 3],
26
  [3.14, "divide", 2],
27
  [144, "multiply", 2.5],
28
  [0, "subtract", 1.2],
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
 
2
- gradio-client @ git+https://github.com/gradio-app/gradio@c20629b1c66e49d4362a479b263da930d835c0c7#subdirectory=client/python
3
- https://gradio-builds.s3.amazonaws.com/c20629b1c66e49d4362a479b263da930d835c0c7/gradio-4.22.0-py3-none-any.whl
4
  pypistats==1.1.0
5
  plotly==5.10.0
6
  opencv-python==4.6.0.66
 
1
 
2
+ gradio-client @ git+https://github.com/gradio-app/gradio@8a6cca7fde56f7ca4755393a5559760a492cdebd#subdirectory=client/python
3
+ https://gradio-builds.s3.amazonaws.com/8a6cca7fde56f7ca4755393a5559760a492cdebd/gradio-4.22.0-py3-none-any.whl
4
  pypistats==1.1.0
5
  plotly==5.10.0
6
  opencv-python==4.6.0.66