towhee.trainer.utils.plot_utilsΒΆ

Functions

image_folder_sample_show

Show sample images for torchvision.datasets.ImageFolder, Put another way, the image root path structure just need to be like this: ` root-|     #classname1#-|         image-1.jpg         image-2.jpg     #classname2-|         image-1.jpg         image-2.jpg     |     |     #classnameN-|         image-1.jpg         image-2.jpg ` it's useful to observe the images for different categories. You can randomly sample categories, or specify show classes. :param root: Root of ImageFolder instance. :type root: str :param rows: Count of show rows. :type rows: int :param cols: Count of show cols. :type cols: int :param img_size: Show image shape, if int, it's a square. :type img_size: int or tuple :param classes: The specified classes you want to see. If not None, param rows will be invalid. :type classes: Optional[list[str]].

image_folder_statistic

Show count statistic infos for torchvision.datasets.ImageFolder. Put another way, the image root path structure just need to be like this: ` root-|     #classname1#-|         image-1.jpg         image-2.jpg     #classname2-|         image-1.jpg         image-2.jpg     |     |     #classnameN-|         image-1.jpg         image-2.jpg ` :param root: Root of ImageFolder instance. :type root: str :param classes: The specified classes of statistic. If not None, all class statistic will be return. :type classes: Optional[List[str]] :param show_bar: Whether showing bar graph. :type show_bar: Optional[bool].

interpret_image_classification

Use Captum to interpret the specified class of network output. Captum should be installed. :param model: Pytorch module. :type model: nn.Module :param image: The image before do transform. It can be produced by either pytorch DataLoader or read by Image.open() using PIL. :type image: Any :param eval_transform: Evaluation transform. :type eval_transform: transforms.Compose :param method: It can be in ['Occlusion', 'IntegratedGradients', 'GradientShap', 'Saliency']. :type method: method :param fig_size: Figure plotting size. :type fig_size: Tuple :param cmap: Matplotlib colormap. :type cmap: Any :param pred_label_idx: If None, use the predicted class automatically. :type pred_label_idx: int :param titles: Plotted titles of the two axs in the figure. :type titles: List :param **kwargs: Keyword Args. :type **kwargs: Any.

plot_lrs_for_config

Plot the lr for a config.

plot_lrs_for_scheduler

Plot the lr curve for a specified optimizer and scheduler instance.

predict_image_classification

Predict using an image classification model.

show_transform

Show the result which torchvision.transforms or any other callable function act on the image.