KIELocalVisualizer¶
- class mmocr.visualization.KIELocalVisualizer(name='kie_visualizer', is_openset=False, **kwargs)[源代码]¶
The MMOCR Text Detection Local Visualizer.
- 参数
name (str) – Name of the instance. Defaults to ‘visualizer’.
image (np.ndarray, optional) – the origin image to draw. The format should be RGB. Defaults to None.
vis_backends (list, optional) – Visual backend config list. Default to None.
save_dir (str, optional) – Save file dir for all storage backends. If it is None, the backend storage will not save any data.
fig_save_cfg (dict) – Keyword parameters of figure for saving. Defaults to empty dict.
fig_show_cfg (dict) – Keyword parameters of figure for showing. Defaults to empty dict.
is_openset (bool, optional) – Whether the visualizer is used in OpenSet. Defaults to False.
- 返回类型
- add_datasample(name, image, data_sample=None, draw_gt=True, draw_pred=True, show=False, wait_time=0, pred_score_thr=None, out_file=None, step=0)[源代码]¶
Draw datasample and save to all backends.
If GT and prediction are plotted at the same time, they are
displayed in a stitched image where the left image is the ground truth and the right image is the prediction. - If
show
is True, all storage backends are ignored, and the images will be displayed in a local window. - Ifout_file
is specified, the drawn image will be saved toout_file
. This is usually used when the display is not available.- 参数
name (str) – The image identifier.
image (np.ndarray) – The image to draw.
data_sample (
KIEDataSample
, optional) –- KIEDataSample which contains gt and prediction. Defaults
to None.
draw_gt (bool) – Whether to draw GT KIEDataSample. Defaults to True.
draw_pred (bool) – Whether to draw Predicted KIEDataSample. Defaults to True.
show (bool) – Whether to display the drawn image. Default to False.
wait_time (float) – The interval of show (s). Defaults to 0.
pred_score_thr (float) – The threshold to visualize the bboxes and masks. Defaults to 0.3.
out_file (str) – Path to output file. Defaults to None.
step (int) – Global step value to record. Defaults to 0.
- 返回类型
- draw_arrows(x_data, y_data, colors='C1', line_widths=1, line_styles='-', arrow_tail_widths=0.001, arrow_head_widths=None, arrow_head_lengths=None, arrow_shapes='full', overhangs=0)[源代码]¶
Draw single or multiple arrows.
- 参数
x_data (np.ndarray or torch.Tensor) – The x coordinate of each line’ start and end points.
y_data (np.ndarray, torch.Tensor) – The y coordinate of each line’ start and end points.
colors (str or tuple or list[str or tuple]) – The colors of lines.
colors
can have the same length with lines or just single value. Ifcolors
is single value, all the lines will have the same colors. Reference to https://matplotlib.org/stable/gallery/color/named_colors.html for more details. Defaults to ‘g’.line_widths (int or float or list[int or float]) – The linewidth of lines.
line_widths
can have the same length with lines or just single value. Ifline_widths
is single value, all the lines will have the same linewidth. Defaults to 2.line_styles (str or list[str]]) – The linestyle of lines.
line_styles
can have the same length with lines or just single value. Ifline_styles
is single value, all the lines will have the same linestyle. Defaults to ‘-‘.arrow_tail_widths (int or float or list[int, float]) – The width of arrow tails.
arrow_tail_widths
can have the same length with lines or just single value. Ifarrow_tail_widths
is single value, all the lines will have the same width. Defaults to 0.001.arrow_head_widths (int or float or list[int, float]) – The width of arrow heads.
arrow_head_widths
can have the same length with lines or just single value. Ifarrow_head_widths
is single value, all the lines will have the same width. Defaults to None.arrow_head_lengths (int or float or list[int, float]) – The length of arrow heads.
arrow_head_lengths
can have the same length with lines or just single value. Ifarrow_head_lengths
is single value, all the lines will have the same length. Defaults to None.arrow_shapes (str or list[str]]) – The shapes of arrow heads.
arrow_shapes
can have the same length with lines or just single value. Ifarrow_shapes
is single value, all the lines will have the same shape. Defaults to ‘full’.overhangs (int or list[int]]) – The overhangs of arrow heads.
overhangs
can have the same length with lines or just single value. Ifoverhangs
is single value, all the lines will have the same overhangs. Defaults to 0.
- 返回类型