Skip to content

Commit

Permalink
Build 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarGracia committed Jul 6, 2024
1 parent b85591e commit 655053d
Show file tree
Hide file tree
Showing 4 changed files with 3,662 additions and 3,493 deletions.
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,38 @@ pip install gradio_image_annotation
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 @@ -44,19 +66,25 @@ 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, image_type="numpy")
annotator_crop = image_annotator(
example_crop,
image_type="numpy",
disable_edit_boxes=True
)
image_crop = gr.Image()
button_crop = gr.Button("Crop")
button_crop.click(crop, annotator_crop, image_crop)
Expand Down Expand Up @@ -185,6 +213,19 @@ int | None
<td align="left">Thickness of the bounding box outline when it is selected.</td>
</tr>

<tr>
<td align="left"><code>disable_edit_boxes</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">Disables the ability to set and edit the label and color of the boxes.</td>
</tr>

<tr>
<td align="left"><code>height</code></td>
<td align="left" style="width: 25%;">
Expand Down
Loading

0 comments on commit 655053d

Please sign in to comment.