aliabd HF staff commited on
Commit
cef93a2
·
1 Parent(s): fdfc482

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +1 -1
  2. run.ipynb +1 -1
  3. run.py +2 -3
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
  tensorflow
2
- https://gradio-main-build.s3.amazonaws.com/e0eea96766b70704016c325b260bdf77147c2f68/gradio-3.27.0-py3-none-any.whl
 
1
  tensorflow
2
+ https://gradio-main-build.s3.amazonaws.com/6e7abf8645661f57a08f88e2bd55d31f101e2065/gradio-3.27.0-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: digit_classifier"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio tensorflow"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["from urllib.request import urlretrieve\n", "\n", "import tensorflow as tf\n", "\n", "import gradio\n", "import gradio as gr\n", "\n", "urlretrieve(\n", " \"https://gr-models.s3-us-west-2.amazonaws.com/mnist-model.h5\", \"mnist-model.h5\"\n", ")\n", "model = tf.keras.models.load_model(\"mnist-model.h5\")\n", "\n", "\n", "def recognize_digit(image):\n", " image = image.reshape(1, -1)\n", " prediction = model.predict(image).tolist()[0]\n", " return {str(i): prediction[i] for i in range(10)}\n", "\n", "\n", "im = gradio.Image(shape=(28, 28), image_mode=\"L\", invert_colors=False, source=\"canvas\")\n", "\n", "demo = gr.Interface(\n", " recognize_digit,\n", " im,\n", " gradio.Label(num_top_classes=3),\n", " live=True,\n", " interpretation=\"default\",\n", " capture_session=True,\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: digit_classifier"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio tensorflow"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["from urllib.request import urlretrieve\n", "\n", "import tensorflow as tf\n", "\n", "import gradio as gr\n", "\n", "urlretrieve(\n", " \"https://gr-models.s3-us-west-2.amazonaws.com/mnist-model.h5\", \"mnist-model.h5\"\n", ")\n", "model = tf.keras.models.load_model(\"mnist-model.h5\")\n", "\n", "\n", "def recognize_digit(image):\n", " image = image.reshape(1, -1)\n", " prediction = model.predict(image).tolist()[0]\n", " return {str(i): prediction[i] for i in range(10)}\n", "\n", "\n", "im = gr.Image(shape=(28, 28), image_mode=\"L\", invert_colors=False, source=\"canvas\")\n", "\n", "demo = gr.Interface(\n", " recognize_digit,\n", " im,\n", " gr.Label(num_top_classes=3),\n", " live=True,\n", " interpretation=\"default\",\n", " capture_session=True,\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -2,7 +2,6 @@ from urllib.request import urlretrieve
2
 
3
  import tensorflow as tf
4
 
5
- import gradio
6
  import gradio as gr
7
 
8
  urlretrieve(
@@ -17,12 +16,12 @@ def recognize_digit(image):
17
  return {str(i): prediction[i] for i in range(10)}
18
 
19
 
20
- im = gradio.Image(shape=(28, 28), image_mode="L", invert_colors=False, source="canvas")
21
 
22
  demo = gr.Interface(
23
  recognize_digit,
24
  im,
25
- gradio.Label(num_top_classes=3),
26
  live=True,
27
  interpretation="default",
28
  capture_session=True,
 
2
 
3
  import tensorflow as tf
4
 
 
5
  import gradio as gr
6
 
7
  urlretrieve(
 
16
  return {str(i): prediction[i] for i in range(10)}
17
 
18
 
19
+ im = gr.Image(shape=(28, 28), image_mode="L", invert_colors=False, source="canvas")
20
 
21
  demo = gr.Interface(
22
  recognize_digit,
23
  im,
24
+ gr.Label(num_top_classes=3),
25
  live=True,
26
  interpretation="default",
27
  capture_session=True,