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

[Feture] kie visualizer #1267

Merged
merged 5 commits into from
Aug 29, 2022
Merged

Conversation

Harold-lkk
Copy link
Collaborator

No description provided.

@Harold-lkk Harold-lkk force-pushed the lkk/kie_visualizer branch 3 times, most recently from 78475f6 to b14c408 Compare August 17, 2022 07:23
@Harold-lkk Harold-lkk changed the base branch from test-1.x to dev-1.x August 17, 2022 07:24
@Harold-lkk Harold-lkk marked this pull request as ready for review August 18, 2022 14:09
@Harold-lkk Harold-lkk force-pushed the lkk/kie_visualizer branch 2 times, most recently from 10f9a64 to e46c95b Compare August 23, 2022 13:10
Comment on lines +78 to +80
if colors is not None and isinstance(colors, Sequence):
size = math.ceil(len(labels) / len(colors))
colors = (colors * size)[:len(labels)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with docstr. Docstr suggesting:

               The colors of labels.
                ``colors`` can be a list of values or just a single
                value. If ``colors`` is a single value, all the labels will have
                the same color. Otherwise, colors will be assigned to
                labels through round robin. Refer to `matplotlib.colors` for the
                full list of formats that are accepted. Defaults to 'k'.

Besides, colors doesn't take effect in this method.

to 10.
auto_font_size (bool): Whether to automatically adjust font size.
Defaults to False.
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns:

mmocr/visualization/kie_visualizer.py Outdated Show resolved Hide resolved
colors: Union[str, Sequence[str]] = 'g',
filling: bool = False,
line_width: Union[int, float] = 0.5,
alpha: float = 0.5) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstr

self.is_openset = is_openset

@staticmethod
def _draw_labels(visualizer: Visualizer,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete, if inherited from BaseLocalVisualizer

pred_img_data = None

if draw_gt:
gt_bboxes = data_sample.gt_instances.bboxes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gt_bboxes = data_sample.gt_instances.bboxes
gt_bboxes = data_sample.gt_instances.get('bboxes', None)

Do the change you have taken my previous suggestions in _draw_instances, same for line 353

Comment on lines 382 to 383
x_datas: Union[np.ndarray, torch.Tensor],
y_datas: Union[np.ndarray, torch.Tensor],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x_datas: Union[np.ndarray, torch.Tensor],
y_datas: Union[np.ndarray, torch.Tensor],
x_data: Union[np.ndarray, torch.Tensor],
y_data: Union[np.ndarray, torch.Tensor],

arrow_shapes (str or list[str]]): The shapes of arrow heads.
``arrow_shapes`` can have the same length with lines or just
single value. If ``arrow_shapes`` is single value, all the
lines will have the same shape. Defaults to 'full'.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Options?

if len(x_datas.shape) == 1:
x_datas = x_datas[None]
y_datas = y_datas[None]
number_arrow = x_datas.shape[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
number_arrow = x_datas.shape[0]
num_arrows = x_datas.shape[0]

Comment on lines +31 to +39
edge_labels (np.ndarray, torch.Tensor): The edge labels to draw.
The shape of edge_labels should be (N, N), where N is the
number of texts.
texts (Sequence[str]): The texts to draw. The length of texts
should be the same as the number of bboxes.
class_names (dict): The class names for bbox labels.
is_openset (bool): Whether the dataset is openset. Default: False.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

del, also don't forget to sync the docstring after updating the counterpart in KIEVisualizer

@gaotongxiao gaotongxiao merged commit bf042f8 into open-mmlab:dev-1.x Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants