x = Dense(10, activation='softmax')(x) model = Model(base_model.input, x) model.load_weights('weights/nasnet_weights.h5') score_list = np.empty((len(imgs), 11), dtype=object) step = 20000 i = 0 while i < len(imgs): print(i) imgs_temp = imgs[i:i + step] img_array = np.empty((len(imgs_temp), 224, 224, 3)) file_names = [] for ind, j in tqdm.tqdm(enumerate(imgs_temp)): x = preprocess_input( np.expand_dims(img_to_array( load_img(j, target_size=target_size)), axis=0)) img_array[ind, ] = x file_names.append(Path(j).name.lower()) scores = model.predict(img_array, batch_size=100, verbose=0) #si = np.arange(1, 11, 1) #mean = np.sum(scores * si, axis=1) #std = np.sqrt(np.sum(((np.array([si, ] * len(imgs_temp)) - mean.reshape(len(imgs_temp), -1)) ** 2) * scores, axis=1)) #result = np.stack([file_names, mean, std]).transpose() #result = np.stack([file_names, scores]).transpose() #score_list[i:i + step, ] = result
pooling='avg', weights=None) x = Dropout(0.75)(base_model.output) x = Dense(10, activation='softmax')(x) model = Model(base_model.input, x) model.load_weights('weights/nasnet_weights.h5') score_list = [] for img_path in imgs: img = load_img(img_path, target_size=target_size) x = img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x) scores = model.predict(x, batch_size=1, verbose=0)[0] mean = mean_score(scores) std = std_score(scores) file_name = Path(img_path).name.lower() score_list.append((file_name, mean)) print("Evaluating : ", img_path) print("NIMA Score : %0.3f +- (%0.3f)" % (mean, std)) print() if rank_images: print("*" * 40, "Ranking Images", "*" * 40)
x = Dropout(0.75)(base_model.output) x = Dense(10, activation='softmax')(x) model = Model(base_model.input, x) model.load_weights('weights/nasnet_weights.h5') score_list = np.empty((len(imgs), 11), dtype=object) step = 20000 i = 0 while i < len(imgs): print(i) imgs_temp = imgs[i:i + step] img_array = np.empty((len(imgs_temp), 224, 224, 3)) file_names = [] for ind, j in tqdm.tqdm(enumerate(imgs_temp)): x = preprocess_input(np.expand_dims(img_to_array(load_img(j, target_size=target_size)), axis=0)) img_array[ind, ] = x file_names.append(Path(j).name.lower()) scores = model.predict(img_array, batch_size=100, verbose=0) #si = np.arange(1, 11, 1) #mean = np.sum(scores * si, axis=1) #std = np.sqrt(np.sum(((np.array([si, ] * len(imgs_temp)) - mean.reshape(len(imgs_temp), -1)) ** 2) * scores, axis=1)) #result = np.stack([file_names, mean, std]).transpose() #result = np.stack([file_names, scores]).transpose() #score_list[i:i + step, ] = result score_list[i:i + step, 0] = file_names
pooling='avg', weights=None) x = Dropout(0.75)(base_model.output) x = Dense(10, activation='softmax')(x) model = Model(base_model.input, x) model.load_weights('weights/nasnet_weights.h5') score_list = [] for img_path in imgs: img = load_img(img_path, target_size=target_size) x = img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x, data_format=tf.keras.backend.image_data_format()) scores = model.predict(x, batch_size=1, verbose=0)[0] mean = mean_score(scores) std = std_score(scores) file_name = Path(img_path).name.lower() score_list.append((file_name, mean)) print("Evaluating : ", img_path) print("NIMA Score : %0.3f +- (%0.3f)" % (mean, std)) print() if rank_images: print("*" * 40, "Ranking Images", "*" * 40)