Skip to content
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

Setting the Color_map argument in 'draw_box' function does not change the color of bounding boxes #106

Closed
venkatesh-kulkarni opened this issue Dec 21, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@venkatesh-kulkarni
Copy link

I have tried setting the color_map argument in 'draw_box' function but it defaults to 'red' color. I believe the reason for the red color is that the DEFAULT_OUTLINE_COLOR in layoutparser.visualization file has been set to 'red'. The official documentation mentions the following to change the color_map:

A map from block.type to the colors, e.g., {1: 'red'}.

I have tried creating the dictionary in the same way but it does not work.
This is the code segment that I am using:

model = lp.Detectron2LayoutModel('lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config', extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.80, "MODEL.ROI_HEADS.NMS_THRESH_TEST", 0.5], label_map = {0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

color_map = {0:'green', 1:'red', 2:'white', 3:'black', 4:'blue'}
for i in range(len(images_path)):
image = cv2.imread(images_path[i])
image = image[..., ::-1]
layout = model.detect(image)
image_new = lp.draw_box(image, layout, box_width=3, color_map = color_map)
image_new.save('image_path.jpg')

@venkatesh-kulkarni venkatesh-kulkarni added the bug Something isn't working label Dec 21, 2021
@lolipopshock
Copy link
Member

You might want to try use the following configuration:

color_map  = {"Text":'green', "Title":'red', "List":'white', "Table":'black', "Figure":'blue'}

The label_map for the models is used to map the numeric model prediction index to the string name (and they are stored in block.type), and the color_map is used for assigning colors based on the block.types.

@lolipopshock lolipopshock added documentation Improvements or additions to documentation and removed bug Something isn't working labels Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants