Skip to content

Commit

Permalink
Updated demo
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarGracia committed Jul 6, 2024
1 parent badd654 commit b85591e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
34 changes: 29 additions & 5 deletions demo/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
import gradio as gr
from gradio_image_annotation import image_annotator

example = {

example_annotation = {
"image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
"boxes": [
{
"xmin": 636,
"ymin": 575,
"xmax": 801,
"ymax": 697,
"label": "Vehicle",
"color": (255, 0, 0)
},
{
"xmin": 360,
"ymin": 615,
"xmax": 386,
"ymax": 702,
"label": "Person",
"color": (0, 255, 0)
}
]
}

example_crop = {
"image": "https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png",
"boxes": [
{
"xmin": 30,
"ymin": 70,
"xmax": 530,
"ymax": 500,
"label": "Gradio",
"color": (250, 185, 0),
"color": (100, 200, 255)
}
]
}
Expand All @@ -29,20 +51,22 @@ def crop(annotations):
def get_boxes_json(annotations):
return annotations["boxes"]


with gr.Blocks() as demo:
with gr.Tab("Object annotation"):
annotator = image_annotator(
{"image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png"},
example_annotation,
label_list=["Person", "Vehicle"],
label_colors=[(0, 255, 0), (255, 0, 0)],
)
button_get = gr.Button("Get bounding boxes")
json_boxes = gr.JSON()
button_get.click(get_boxes_json, annotator, json_boxes)

with gr.Tab("Crop"):
with gr.Row():
annotator_crop = image_annotator(
example,
example_crop,
image_type="numpy",
disable_edit_boxes=True
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-backend = "hatchling.build"

[project]
name = "gradio_image_annotation"
version = "0.0.8"
version = "0.1.0"
description = "A Gradio component that can be used to annotate images with bounding boxes."
readme = "README.md"
license = "MIT"
Expand Down

0 comments on commit b85591e

Please sign in to comment.