【发布时间】:2013-09-24 20:21:37
【问题描述】:
我想构建一个服装分类器,对一件衣服拍照并将其分类为“牛仔裤”、“连衣裙”、“运动鞋”等。
一些例子:
这些图片来自零售商网站,因此通常是从同一角度拍摄的,通常是在白色或浅色背景上——它们往往非常相似。
我有一组数千张我已经知道其类别的图像,我可以用它们来训练机器学习算法。
但是,我正在努力寻找应该使用哪些功能的想法。我目前拥有的功能:
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
我正在提取一个简单的 13x13 灰度网格作为形状的粗略近似。但是,将这些功能与 nltk 的 NaiveBayesClassifier 一起使用只能使我获得 34% 的准确率。
哪些功能在这里可以很好地发挥作用?
【问题讨论】:
-
如果你使用比 13x13 更大的图像,你会得到更好的精度吗?
-
@JoranBeasley 移动到 20x20 图像实际上会降低 2% 的准确性并显着影响性能。
-
如果您将其简化为“鞋还是不鞋”并以此开始...可能会更改您的某些分类(我不知道您是否手动设置分类,而不是使用 bltk)
-
致那些将此问题标记为过于宽泛的人:您认为有可能进行更改以使其不那么宽泛,还是无法解决?我在谈论一个特定的数据集,并收到了一些很好的答案。
标签: python machine-learning computer-vision image-recognition