freddyaboulton HF Staff commited on
Commit
e47ea51
·
verified ·
1 Parent(s): 648642f

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. requirements.txt +5 -2
  3. run.ipynb +1 -1
  4. run.py +7 -20
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,5 @@
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
+ numpy
4
+ requests
5
+ Pillow
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: annotatedimage_component"]}, {"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 pathlib\n", "from PIL import Image\n", "import numpy as np\n", "import urllib.request\n", "\n", "source_dir = pathlib.Path(__file__).parent\n", "\n", "urllib.request.urlretrieve(\n", " 'https://gradio-builds.s3.amazonaws.com/demo-files/base.png',\n", " str(source_dir / \"base.png\")\n", ")\n", "urllib.request.urlretrieve(\n", " \"https://gradio-builds.s3.amazonaws.com/demo-files/buildings.png\",\n", " str(source_dir / \"buildings.png\")\n", ")\n", "\n", "base_image = Image.open(str(source_dir / \"base.png\"))\n", "building_image = Image.open(str(source_dir / \"buildings.png\"))\n", "\n", "# Create segmentation mask\n", "building_image = np.asarray(building_image)[:, :, -1] > 0\n", "\n", "with gr.Blocks() as demo:\n", " gr.AnnotatedImage(\n", " value=(base_image, [(building_image, \"buildings\")]),\n", " height=500,\n", " )\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: annotatedimage_component"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy requests Pillow "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np \n", "import requests \n", "from io import BytesIO\n", "from PIL import Image\n", "\n", "base_image = \"https://gradio-docs-json.s3.us-west-2.amazonaws.com/base.png\"\n", "building_image = requests.get(\"https://gradio-docs-json.s3.us-west-2.amazonaws.com/buildings.png\")\n", "building_image = np.asarray(Image.open(BytesIO(building_image.content)))[:, :, -1] > 0\n", "\n", "with gr.Blocks() as demo:\n", " gr.AnnotatedImage(\n", " value=(base_image, [(building_image, \"buildings\")]),\n", " height=500,\n", " )\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,25 +1,12 @@
1
  import gradio as gr
2
- import pathlib
 
 
3
  from PIL import Image
4
- import numpy as np
5
- import urllib.request
6
 
7
- source_dir = pathlib.Path(__file__).parent
8
-
9
- urllib.request.urlretrieve(
10
- 'https://gradio-builds.s3.amazonaws.com/demo-files/base.png',
11
- str(source_dir / "base.png")
12
- )
13
- urllib.request.urlretrieve(
14
- "https://gradio-builds.s3.amazonaws.com/demo-files/buildings.png",
15
- str(source_dir / "buildings.png")
16
- )
17
-
18
- base_image = Image.open(str(source_dir / "base.png"))
19
- building_image = Image.open(str(source_dir / "buildings.png"))
20
-
21
- # Create segmentation mask
22
- building_image = np.asarray(building_image)[:, :, -1] > 0
23
 
24
  with gr.Blocks() as demo:
25
  gr.AnnotatedImage(
@@ -27,4 +14,4 @@ with gr.Blocks() as demo:
27
  height=500,
28
  )
29
 
30
- demo.launch()
 
1
  import gradio as gr
2
+ import numpy as np
3
+ import requests
4
+ from io import BytesIO
5
  from PIL import Image
 
 
6
 
7
+ base_image = "https://gradio-docs-json.s3.us-west-2.amazonaws.com/base.png"
8
+ building_image = requests.get("https://gradio-docs-json.s3.us-west-2.amazonaws.com/buildings.png")
9
+ building_image = np.asarray(Image.open(BytesIO(building_image.content)))[:, :, -1] > 0
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  with gr.Blocks() as demo:
12
  gr.AnnotatedImage(
 
14
  height=500,
15
  )
16
 
17
+ demo.launch()