Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Автоматизация интернет-знакомств

Автоматизация интернет-знакомств

Азамат Галимжанов @ Moscow Python 35

Moscow Python Meetup

May 23, 2016
Tweet

More Decks by Moscow Python Meetup

Other Decks in Programming

Transcript

  1. Знакомство • Азамат, 26 лет, бородат • 5 лет python

    • Стартап «ГдеМатериал» • В Москве недавно
  2. Знакомство с dlib • Библиотека ML, написана на С++ •

    Есть встроенные методы для нахождения лица • shape_predictor_68_face_landmarks.dat
  3. ratios = [] points = get_landmarks(img) combinations = itertools.combinations(points, 4)

    for cmb in combinations: d1 = np.linalg.norm(cmb[0] - cmb[1]) d2 = np.linalg.norm(cmb[2] - cmb[3]) ratio = d1 / d2 ratios.append(ratio)
  4. combinations = list(itertools.combinations(landmarks, 4)) cmbs = np.asarray(combinations) # Each combination

    is 4 points column_1 = cmbs[:,0] column_2 = cmbs[:,1] column_3 = cmbs[:,2] column_4 = cmbs[:,3] # Get distances between each pair of points diff1 = column_1 - column_2 diff2 = column_3 - column_4 d1 = np.sqrt((diff1 * diff1).sum(axis=1)) d2 = np.sqrt((diff2 * diff2).sum(axis=1)) # Get ratio of these distances features = d1 / d2
  5. pictures = Picture.objects.exclude(rating=0) for pic in pictures: img = Image.open(pic.img.path)

    faces, landmarks = get_landmarks(img) pic.features = get_features(landmarks) pic.save()