Skip to content

Instantly share code, notes, and snippets.

@Gabe-flomo
Last active September 28, 2020 21:17
Embed
What would you like to do?
data = {}
p = r"E:\Documents\My Projects\Instagram Dashboard\Model Development\flower_features.pkl"
# lop through each image in the dataset
for flower in flowers:
# try to extract the features and update the dictionary
try:
feat = extract_features(flower,model)
data[flower] = feat
# if something fails, save the extracted features as a pickle file (optional)
except:
with open(p,'wb') as file:
pickle.dump(data,file)
# get a list of the filenames
filenames = np.array(list(data.keys()))
# get a list of just the features
feat = np.array(list(data.values()))
feat.shape
(210, 1, 4096)
# reshape so that there are 210 samples of 4096 vectors
feat = feat.reshape(-1,4096)
feat.shape
(210, 4096)
# get the unique labels (from the flower_labels.csv)
df = pd.read_csv('flower_labels.csv')
label = df['label'].tolist()
unique_labels = list(set(label))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment