Wil*_*hes 12 python machine-learning image-recognition computer-vision
我想建立一个服装分类器,拍摄一件衣服的照片,并将其分类为"牛仔裤","礼服","运动鞋"等.
一些例子:

这些图像来自零售商网站,因此通常从相同的角度拍摄,通常在白色或苍白的背景上 - 它们往往非常相似.
我有一组数千个我已经知道的类别的图像,我可以用来训练机器学习算法.
但是,我正在努力寻找我应该使用哪些功能的想法.到目前为止我的功能:
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
Run Code Online (Sandbox Code Playgroud)
我正在提取一个简单的13x13灰度网格作为形状的粗略近似.Howerver,使用nltk的这些功能NaiveBayesClassifier只能让我获得34%的准确率.
哪些功能在这里运作良好?
jab*_*edo 10
这是一个棘手的问题,因此有很多方法.
上常用的方法(虽然复杂)被取输入图像,superpixelate图像并计算描述符(如SIFT的SURF那些超像素构建通过累积每超像素直方图的袋的字表示的),该操作提取从密钥信息一堆像素减少维数.然后,条件随机场算法搜索图像中的超像素之间的关系,并对已知类别内的像素组进行分类.对于像素化图像scikit-image包实现SLIC算法segmentation.slic,对于CRF,你应该看看PyStruct包.可以使用OpenCV计算SURF和SIFT.

另一个简单的版本是给定图像的计算描述符(SIFT,SURF,边界,直方图等)并将它们用作分类器算法中的输入,您可能希望从这里开始,也许scikit-learn.org是最简单和最强大的包.
| 归档时间: |
|
| 查看次数: |
3101 次 |
| 最近记录: |