什么是好的功能分类服装的照片? [英] What are good features for classifying photos of clothing?

查看:169
本文介绍了什么是好的功能分类服装的照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个服装分类器,拍摄一件衣服的照片,并将其分类为牛仔裤,衣服,培训师等。



一些示例:







这些图片来自零售商网站,因此通常是从相同的角度拍摄,通常是在白色或苍白的背景上 - - 他们往往是非常相似。



我有一组几千个图像的类别我已经知道,我可以用来训练一个机器学习算法。 / p>

但是,我在努力想要使用什么功能。我到目前为止的功能:

  def get_aspect_ratio(pil_image):
_,_,width,height = pil_image .getbbox()

返回宽度/高度


def get_greyscale_array(pil_image):
将图像转换为13x13正方形灰度图像,并返回
颜色值列表0-255

我选择了13x13,因为它很小,但仍然允许你
区分牛仔裤上的腿之间的差距我的测试


grayscale_image = pil_image.convert('L')
small_image = grayscale_image.resize((13,13),Image.ANTIALIAS)

pixels = []
for y in range(13):
for x in range(13):
pixels.append(small_image.getpixel((x,y )))

返回像素


def get_image_features(image_path):
image = Image.open(open(image_path,'rb'))

features = {}
features ['aspect_ratio'] = get_aspect_ratio(image)

索引,枚举中的像素(get_greyscale_array(image)):
features [pixel%s%index] = pixel

return features

我提取一个简单的13x13灰度网格作为形状的粗略近似。 Howerver,使用这些功能与nltk的 NaiveBayesClassifier 只有我34%的准确性。



哪些功能在这里有效?

解决方案

棘手的问题,因此有很多方法。



在常见的方法(虽然复杂)是输入图像,超像素化图像和计算描述符(如是最简单和最强大的程序包。


I want to build a clothing classifier that takes a photo of an item of clothing and classifies it as 'jeans', 'dress', 'trainers' etc.

Some examples:

These images are from retailer websites, so are typically taken from the same angle, typically on a white or pale background -- they tend to be very similar.

I have a set of several thousand images whose category I already know, which I can use to train a machine-learning algorithm.

However, I'm struggling for ideas of what features I should use. The features I have so far:

def get_aspect_ratio(pil_image):
    _, _, width, height = pil_image.getbbox()

    return width / height


def get_greyscale_array(pil_image):
    """Convert the image to a 13x13 square grayscale image, and return a
    list of colour values 0-255.

    I've chosen 13x13 as it's very small but still allows you to
    distinguish the gap between legs on jeans in my testing.

    """
    grayscale_image = pil_image.convert('L')
    small_image = grayscale_image.resize((13, 13), Image.ANTIALIAS)

    pixels = []
    for y in range(13):
        for x in range(13):
            pixels.append(small_image.getpixel((x, y)))

    return pixels


def get_image_features(image_path):
    image = Image.open(open(image_path, 'rb'))

    features = {}
    features['aspect_ratio'] = get_aspect_ratio(image)

    for index, pixel in enumerate(get_greyscale_array(image)):
        features["pixel%s" % index] = pixel

    return features

I'm extracting a simple 13x13 grayscale grid as a crude approximation of shape. Howerver, using these features with nltk's NaiveBayesClassifier only gets me 34% accuracy.

What features would work well here?

解决方案

This is a tough problem and therefore there are many approaches.

On common method (although complicated) is taken an input image, superpixelate the image and compute descriptors (such as SIFT of SURF) of those superpixels building a bag-of-word representation by accumulating histograms per superpixel, this operation extracts the key information from a bunch of pixels reducing dimensionality. Then a Conditional Random Field algorithm searches for relationships between superpixels in the image and classifies the group of pixels inside a known category. For pixelating images scikit-image package implements SLIC algorithm segmentation.slic, and for the CRF you should take a look to PyStruct package. SURF and SIFT can be calculated using OpenCV.

Another simple version would be computing descriptors of a given image (SIFT, SURF, borders, histogram etc) and use them as inputs in a classifier algorithm, you might want start from here, maybe scikit-learn.org is the easiest and most powerful package for doing this.

这篇关于什么是好的功能分类服装的照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆