-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Annotation per image #10
Comments
Hi @UrbanSolution This should work already - you can certainly add multiple polygons to one image using the superintendent / ipyannotate combination. Simply:
does this not work for you? |
Sorry, the post is not specific enough. I am trying to get the text within a Polygon. Which means that for a given image, the goal is extract multiple polygons along with the text that it contains. I did not manage to build this part. |
OK, I see. That is a slightly more difficult issue, but I can see why you would need this. I will implement this, but it might not be for a while. You could try "composing" the widget yourself, using this strategy:
|
I will try it. Thank you for the help. |
Hi @janfreyberg. from ipyannotations import PolygonAnnotator
from ipywidgets import VBox, Textarea, HBox
text = Textarea(description='Text:', layout={'width': '99%'})
widget = PolygonAnnotator(canvas_size=[800, 1000], options=list(map(str, range(10))))
widget.display("../../data/Datasets/Master_Invoices/invoice-002181-lay008.png")
widget.children = widget.children[::-1]
data_widgets = widget.children[0].children[1]
data_widgets.children = (data_widgets.children[0],
VBox((data_widgets.children[1], text)),
*data_widgets.children[2:])
widget.on_submit(lambda x: x.update(text=text.value))
widget |
Hi @thomassajot, thanks for your message! And apologies for not responding about contributing - I was busy at the time and must have just missed it. That looks like an interesting usecase and I like the UI you have with the Text box. But it sounds like there needs to be better integration between the I think the way to achieve this is to edit the following class: You probably want to add an optional argument to the Annotator class to set the "class selector" to a However, this means you can't both a class label and a free-text string. Is that something you need? If so, it's probably better to add an additional widget, instead of replacing the "class selector" widget. |
PS: I will move this issue over to ipyannotations, as that is probably where the changes need to be made. |
Hi @janfreyberg |
Hi, OK - thanks for the feedback. I think I have a solution that works quite well and is generalisable. I have pushed a new branch called The way it works:
for example: from ipyannotations import BoxAnnotator
import ipywidgets as widgets
input_widget = BoxAnnotator(
options=["a", "b"],
extra_inputs={
"text": widgets.Textarea(description="Text:")
}
)
input_widget.display("https://doc.laserfiche.com/laserfiche.documentation/english/docs/Subsystems/ProcessAutomation/Content/Images/previewtestvalues.png")
input_widget After you draw a box, you can enter text (e.g. John Smith, as I have done in the screenshot). This is then accessible in the input_widget.data
# Output:
# [{'type': 'box',
# 'label': 'a',
# 'xyxy': (527, 120, 575, 138),
# 'text': 'Invoice'},
# {'type': 'box',
# 'label': 'a',
# 'xyxy': (74, 195, 143, 216),
# 'text': 'John Smith'}] |
Is it possible to have multiple label for the same sample (image, text, ...).
Example use-case, related to janfreyberg/superintendent#48, is to identify all polygons within the same image and being able to see them all at once.
A workaround so far is to duplicate the sample n times. However, if not enough duplicates are provided, then the user has to copy the labels, and recreate the Labeller with more duplicates.
The text was updated successfully, but these errors were encountered: