'How to display existing annotations in dcc.Graph

I'm working on a tool that loads some of my precomputed annotations in the form of

bboxes = [ 
  ((x0, y0), (x1, y1)), # annot 1
   ...                  # more annots
]

And I want to display these annotations in rectangle bboxes so that the users can view & edit them, and manually add more by drawing.
Currently I'm using dcc.Graph like this tutorial: https://dash.plotly.com/annotations
Following the tutorial, it is easy to write:

img = cv2.imread('./18.png')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
fig = px.imshow(img, binary_string=True)
fig.update_layout(dragmode="drawrect")

# use in app.layout:

dcc.Graph(
    id="graph-pic-camera", 
    figure=fig
)

But I don't know how to display the bboxes via the API. I know it's easy to display these annotations as rectangle by updating them on the figure, but in this way they will become uneditable. Is there any way to make them editable by passing some kwargs to dcc.Graph? I've tried dcc.Graph.relayoutData, but that param seems to be read-only. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source