interactive annotation about <TextArea> with perRegion="true"
Hi~ Thanks for this wonderful project. Currently, I try to perform interactive annotation for automatically polishing the description of each bbox region via a LLM, which looks like
<Image name="image" value="$image">
<RectangleLabels name="bbox" toName="image">
<Label value="car" />
<Label value="cat" />
</RectangleLabels>
<TextArea name="description" toName="image" perRegion="true" maxSubmissions="1" editable="true" required="true"/>
However, when I submit the text, I am unable to transmit the annotated description to the predict function in the label-studio-ml backend.
It seems perRegion="true" disables this process. How could I address this issue? Thanks.
Hello,
Thanks for the details and the config snippet. What you’re running into is expected: when you attach a TextArea as a perRegion control, Label Studio does not include its value in the top-level params of the ML request. Instead, your user-entered text shows up only in the tasks[0].annotations[0].result list.
Two ways to work around this:
-
Parse the description out of
tasks[0].annotations[0].resultin yourpredictfunction In your ML-backend code, pull the textarea value for the region by matching the region ID (region_idis passed inkwargs). For example:def predict(self, tasks, **kwargs): task = tasks[0] # single‐task region_id = kwargs.get("region_id") # passed by LS for interactive calls results = task["annotations"][0]["result"] # find the description text for this region desc = "" for r in results: if r["type"] == "textarea" and r["id"] == region_id: desc = r["value"]["text"][0] break # now you have the per-region description to feed into your LLM polished = call_your_llm(desc) return [{ "result": [{ "id": region_id, "type": "textarea", "from_name": "description", "to_name": "image", "value": { "text": [polished] } }] }]
-
If you don’t strictly need per-region text, remove
perRegion="true"A non-perRegionTextAreawill have its value sent inparams["context"], which some ML backends read automatically. But that applies the same description to the whole image, not each box.
Thank you, Abu
Comment by Abubakar Saad Workflow Run