def removeImagesNotOutfit(): follow = db.getIgFollowing() for user in follow: img_files = os.listdir('ig_img/' + user + '/') for img_file in img_files: path = 'ig_img/' + user + '/' + img_file img_util.removeIfNotOutfit(path)
def resizeIgImages(): follow = db.getIgFollowing() filenames = [] for user in follow: img_files = os.listdir('ig_img/' + user + '/') for img_file in img_files: path = 'ig_img/' + user + '/' + img_file filenames.append(path) for filename in filenames: img = cv2.imread(filename) img = cv2.resize(img, (400, int(img.shape[1] * (400 / img.shape[0])))) cv2.imwrite(filename, img)
def visualizeIgDatabase(): follow = db.getIgFollowing() filenames = [] for user in follow: img_files = os.listdir('ig_img/' + user + '/') for img_file in img_files: path = 'ig_img/' + user + '/' + img_file filenames.append(path) random.shuffle(filenames) filenames = filenames[:4] for filename in filenames: img = cv2.imread(filename) cv2.destroyAllWindows() cv2.imshow('', img) cv2.waitKey() cv2.destroyAllWindows()
def getOutfit(): weather_data = weather.getWeather() print(weather_data) clothing_encode = [] clothing_weather = [] clothing_type = [] clothing_db = db.getClothingDatabase() for _, entry in clothing_db.items(): img = cv2.imread(entry['path']) enc = style.getStyleEncodeFromImg(img) clothing_encode.append(enc) if 'pants' in entry['tags']: clothing_type.append('lower') elif 'shirt' in entry['tags']: clothing_type.append('upper') else: clothing_type.append('-----') if 'pants' in entry['tags']: clothing_weather.append('cold') elif 'shorts' in entry['tags']: clothing_weather.append('hot') else: clothing_weather.append('warm') ig_clothing_encode = [] ig_clothing_type = [] follow = db.getIgFollowing() for user in follow: img_files = os.listdir('ig_img/' + user + '/') for img_file in img_files: path = 'ig_img/' + user + '/' + img_file img = cv2.imread(path) img_upper, img_lower = img_util.split_clothing(img) enc = style.getStyleEncodeFromImg(img_upper) ig_clothing_encode.append(enc) ig_clothing_type.append('upper') enc = style.getStyleEncodeFromImg(img_lower) ig_clothing_encode.append(enc) ig_clothing_type.append('lower') print(clothing_encode) print(clothing_type) print(ig_clothing_encode) print(ig_clothing_type)
def getImagesFromIgFollows(): follow = db.getIgFollowing() for user in follow: getImagesFromIgUser(user, 3) resizeIgImages() removeImagesNotOutfit()