This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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