mindvision.utils

Init charts tools

mindvision.utils.accuracy_model_flops_chart(accuracy_data: Dict, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

The function is used to plot the accuracy comparison between architectures on different pre-trained compute.

Parameters
  • accuracy_data (dict) – The accuracy of model on different pre-trained compute.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of chart. Default:None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> accuracy_data = {
...        'Transform(ViT)': {
...            "vit-B_32_7": {55: 80.73},
...            "ViT-B_16_7": {224: 84.15},
...            "ViT-L_32_7": {196: 84.37},
...            "ViT-L_16_7": {783: 86.30}
...        }
...    }
>>> accuracy_model_flops_chart(accuracy_data=accuracy_data, ylim=[75, 90])
mindvision.utils.accuracy_model_size_chart(accuracy_data: Dict, size_unit: str, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

The function is used to plot the accuracy comparison between models on different pre-trained dataset size.

Parameters
  • accuracy_data (dict) – The accuracy of model on different pre-trained dataset size.

  • size_unit – Units for dataset size.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of chart. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> accuracy_data = {
...        'ViT-b_32': {
...            10: 37,
...            30: 41,
...            100: 41.5
...        },
...        'ViT-B_32': {
...            10: 38,
...            30: 53,
...            100: 54
...        }
...    }
>>> accuracy_model_size_chart(accuracy_data=accuracy_data, size_unit='M')
mindvision.utils.accuracy_on_dataset_chart_v1(accuracy_data: Dict, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

The function is used to plot the accuracy range between models on different dataset.

Parameters
  • accuracy_data (dict) – The data of line chart models.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of chart. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> accuracy_data = {
...        'ResNet50': {
...            'accuracy': {
...                'ImageNet': 76.8,
...                'ImageNet21K': 80.2,
...                'JFT-300M': 79.2,
...            },
...            'marker_size': 4
...        },
...        'ResNet152': {
...            'accuracy': {
...                'ImageNet': 81.2,
...                'ImageNet21K': 85.5,
...                'JFT-300M': 87.8,
...            },
...            'marker_size': 6
...        }
...    }
>>> accuracy_on_dataset_chart_v1(accuracy_data=accuracy_data)
mindvision.utils.accuracy_on_dataset_chart_v2(accuracy_data: Dict, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

The function is used to plot the accuracy comparison between models on different dataset.

Parameters
  • accuracy_data (dict) – The data of scatter models.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of chart. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> accuracy_data = {
...        'ViT-B_32': {
...            'accuracy': {
...                'ImageNet': 73.38,
...                'ImageNet21K': 81.28,
...                'JFT-300M': 80.73,
...            },
...            'marker_size': 45
...        }
...    }
>>> accuracy_on_dataset_chart_v2(accuracy_data=accuracy_data)
mindvision.utils.accuracy_on_dataset_chart_v3(line_models_data: Dict, scatter_models_data: Dict, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

The function is used to plot the accuracy comparison between architectures on different dataset.

Parameters
  • line_models_data (dict) – The data of line chart models.

  • scatter_models_data (dict) – The data of scatter models.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of chart. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> line_models_data = {
...        'ResNet50': {
...            'accuracy': {
...                'ImageNet': 76.8,
...                'ImageNet21K': 80.2,
...                'JFT-300M': 79.2,
...            },
...            'marker_size': 4
...        },
...        'ResNet152': {
...            'accuracy': {
...                'ImageNet': 81.2,
...                'ImageNet21K': 85.5,
...                'JFT-300M': 87.8,
...            },
...            'marker_size': 6
...        }
...    }
>>> scatter_models_data = {
...        'ViT-B_32': {
...            'accuracy': {
...                'ImageNet': 73.38,
...                'ImageNet21K': 81.28,
...                'JFT-300M': 80.73,
...            },
...             'marker_size': 45
...         }
...     }
>>> accuracy_on_dataset_chart_v3(line_models_data=line_models_data,
...                                 scatter_models_data=scatter_models_data)
mindvision.utils.pos_embedding_cosine_chart(pos_embedding: np.ndarray, save_path: str = './', title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None, colorbar_label: Optional[str] = None)[source]

The function is used to plot the cosine similarity of position embedding.

Parameters
  • pos_embedding (ndarray) – The data of position embedding.

  • save_path (str) – Path to save the chart. Default: ‘./’.

  • title (str, optional) – The title of chart. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

  • colorbar_label (str, optional) – The Label of colorbar. Default: None.

Examples

>>> pos_embedding = np.random.randn(1, 50, 768)
>>> pos_embedding_cosine_chart(pos_embedding=pos_embedding)
mindvision.utils.topn_accuracy_chart(accuracy_data: Dict, save_path: str = './', ylim: Optional[List] = None, figsize: Optional[Tuple] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None)[source]

Accuracy charts, xlabel can be network models or iteration numbers, ylabel is the accuracy.

Parameters
  • accuracy_data (dict) – The accuracy data of models on different AI frame.

  • save_path (str) – The save path of line chart. Default: ‘./’.

  • ylim (list, optional) – The range of y coordinate. Default: None.

  • figsize (tuple, optional) – The size of figure. Default: None.

  • title (str, optional) – The title of graph. Default: None.

  • xlabel (str, optional) – The Label of x coordinate. Default: None.

  • ylabel (str, optional) – The Label of y coordinate. Default: None.

Examples

>>> accuracy_data = {'MindSpore': {'Resnet18': 70.078, 'Resnet34': 73.72, 'Resnet50': 76.6},
...                  'Pytorch': {'Resnet18': 69.758, 'Resnet34': 73.31, 'Resnet50': 76.13}}
>>> topn_accuracy_chart(accuracy_data=accuracy_data)