from scipy.io import loadmat from matplotlib import pyplot as plt import numpy as np from os.path import basename import shutil import random import os import h5py from PIL import Image import pandas as pd from glob import glob import pickle !apt install -y caffe-cuda !pip install pydensecrf import caffe from pydensecrf import densecrf as dcrf from pydensecrf.utils import compute_unary, create_pairwise_bilateral, create_pairwise_gaussian, softmax_to_unary import skimage.io as io import warnings warnings.filterwarnings('ignore') !git clone https://github.com/bearpaw/clothing-co-parsing.git data_path = '/content/clothing-co-parsing/' loadmat(data_path+'annotations/pixel-level/0001.mat') plt.figure(figsize=(12, 8)) plt.subplot(1, 2, 1) img1 = Image.open(data_path+'photos/0001.jpg') plt.imshow(img1) plt.subplot(1, 2, 2) mask1 = loadmat(data_path+'annotations/pixel-level/0001.mat')['groundtruth'] plt.imshow(mask1) plt.show() # reading names of categories in the ccp dataset and saving it as csv labels = loadmat(data_path+'label_list.mat') ccp_categories = [] for i in labels['label_list'][0]: ccp_categories.append(str(i[0])) color_map = pd.Series(ccp_categories) color_map