def image_folder_statistic(root: str, classes: Optional[List[str]] = None, show_bar: Optional[bool] = False):
    """
    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
    ```
    Args:
        root (`str`):
            Root of `ImageFolder` instance.
        classes (`Optional[List[str]]`):
            The specified classes of statistic. If not None, all class statistic will be return.
        show_bar (`Optional[bool]`):
            Whether showing bar graph.

    Returns:
        (`dict`)
            Count statistic info, where key is category name, value is the count.
    """
    if not is_matplotlib_available():
        trainer_log.warning('Matplotlib is not available.')
    from towhee.utils.matplotlib_utils import matplotlib
    import matplotlib.pylab as plt  # pylint: disable=import-outside-toplevel

    root_path = Path(root)
    if classes:
        class_list = [root_path / cls for cls in classes]
    else:
        class_list = os.listdir(root)
    count_dict = {}
    for cls in class_list:
        cls_num = len(list((root_path / cls).iterdir()))
        count_dict[cls] = cls_num
    if show_bar:
        plt.figure(figsize=(30, 10))
        plt.bar(x=count_dict.keys(), height=count_dict.values(), color='red')
        plt.xticks(rotation=90)
        plt.tight_layout()
        plt.grid(True)
        plt.title(root_path.name)
        plt.show()
    return count_dict
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
```
Args:
root (`str`):
Root of `ImageFolder` instance.
classes (`Optional[List[str]]`):
The specified classes of statistic. If not None, all class statistic will be return.
show_bar (`Optional[bool]`):
Whether showing bar graph.

Returns:
(`dict`)
Count statistic info, where key is category name, value is the count.
towhee/trainer/utils/plot_utils.py