freddyaboulton HF Staff commited on
Commit
72b4378
·
verified ·
1 Parent(s): 121de5e

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 +6 -5
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@327015b7dca90f17f174baee9f3c966a48fe4775#subdirectory=client/python
2
- https://gradio-pypi-previews.s3.amazonaws.com/327015b7dca90f17f174baee9f3c966a48fe4775/gradio-5.47.2-py3-none-any.whl
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@070463cf85f75f1a327a2c0daa6eea81467ad749#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/070463cf85f75f1a327a2c0daa6eea81467ad749/gradio-5.47.2-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: image_mod"]}, {"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('images')\n", "!wget -q -O images/cheetah1.jpg https://github.com/gradio-app/gradio/raw/main/demo/image_mod/images/cheetah1.jpg\n", "!wget -q -O images/lion.jpg https://github.com/gradio-app/gradio/raw/main/demo/image_mod/images/lion.jpg\n", "!wget -q -O images/logo.png https://github.com/gradio-app/gradio/raw/main/demo/image_mod/images/logo.png\n", "!wget -q -O images/tower.jpg https://github.com/gradio-app/gradio/raw/main/demo/image_mod/images/tower.jpg"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "\n", "def image_mod(image):\n", " return image.rotate(45)\n", "\n", "new_samples = [\n", " [os.path.join(os.path.abspath(''), \"images/logo.png\")],\n", " [os.path.join(os.path.abspath(''), \"images/tower.jpg\")],\n", "]\n", "\n", "with gr.Blocks() as demo:\n", " interface = gr.Interface(\n", " image_mod,\n", " gr.Image(type=\"pil\"),\n", " \"image\",\n", " flagging_options=[\"blurry\", \"incorrect\", \"other\"],\n", " examples=[\n", " os.path.join(os.path.abspath(''), \"images/cheetah1.jpg\"),\n", " os.path.join(os.path.abspath(''), \"images/lion.jpg\"),\n", " ],\n", " )\n", "\n", " btn = gr.Button(\"Update Examples\")\n", " btn.click(lambda : gr.Dataset(samples=new_samples), None, interface.examples_handler.dataset)\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: image_mod"]}, {"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", "from gradio.media import get_image\n", "\n", "def image_mod(image):\n", " return image.rotate(45)\n", "\n", "# get_image() returns file paths to sample media included with Gradio\n", "new_samples = [\n", " [get_image(\"logo.png\")],\n", " [get_image(\"tower.jpg\")],\n", "]\n", "\n", "with gr.Blocks() as demo:\n", " interface = gr.Interface(\n", " image_mod,\n", " gr.Image(type=\"pil\"),\n", " \"image\",\n", " flagging_options=[\"blurry\", \"incorrect\", \"other\"],\n", " examples=[\n", " get_image(\"cheetah1.jpg\"),\n", " get_image(\"lion.jpg\"),\n", " ],\n", " )\n", "\n", " btn = gr.Button(\"Update Examples\")\n", " btn.click(lambda : gr.Dataset(samples=new_samples), None, interface.examples_handler.dataset)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,12 +1,13 @@
1
  import gradio as gr
2
- import os
3
 
4
  def image_mod(image):
5
  return image.rotate(45)
6
 
 
7
  new_samples = [
8
- [os.path.join(os.path.dirname(__file__), "images/logo.png")],
9
- [os.path.join(os.path.dirname(__file__), "images/tower.jpg")],
10
  ]
11
 
12
  with gr.Blocks() as demo:
@@ -16,8 +17,8 @@ with gr.Blocks() as demo:
16
  "image",
17
  flagging_options=["blurry", "incorrect", "other"],
18
  examples=[
19
- os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
20
- os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
21
  ],
22
  )
23
 
 
1
  import gradio as gr
2
+ from gradio.media import get_image
3
 
4
  def image_mod(image):
5
  return image.rotate(45)
6
 
7
+ # get_image() returns file paths to sample media included with Gradio
8
  new_samples = [
9
+ [get_image("logo.png")],
10
+ [get_image("tower.jpg")],
11
  ]
12
 
13
  with gr.Blocks() as demo:
 
17
  "image",
18
  flagging_options=["blurry", "incorrect", "other"],
19
  examples=[
20
+ get_image("cheetah1.jpg"),
21
+ get_image("lion.jpg"),
22
  ],
23
  )
24