image_num = len(image_path) print("图片数量 ",image_num) return image_path,image_num if __name__ == '__main__': start = time.time() #提取image路径文件 # with open("image_reference_cache_amazon.defaultdict", "rb") as file: # data = pk.load(file) with open("result/imagenet_baidu_ref2000.pkl", "rb") as file: data = pk.load(file) image_path,image_num = get_image_path(data) #上传原图到云服务器 # cloud_agent = FacePP() cloud_agent = Baidu() # cloud_agent = AmazonRekognition() ref_quality = 75 cache = defaultdict(dict) deepn_cache = defaultdict(dict) compare_cache = defaultdict(dict) # 导入之前结果 # with open("result/Origin_Baidu.defaultdict", 'rb') as file: # cache = pk.load(file) # with open("result/DeepN_Baidu.defaultdict", 'rb') as file: # deepn_cache = pk.load(file) # with open("result/Compare_Baidu.defaultdict", 'rb') as file: # compare_cache = pk.load(file) num1 = image_num # num1 = 30 for i in range(num1):
def estimate(self): if len(self.agent_memory['reward']) < self.recent_zone: recent_reward = np.mean(self.agent_memory['reward']) recent_acc = np.mean(self.agent_memory['accuracy']) else: recent_reward = np.mean( self.agent_memory['reward'][-self.recent_zone:]) recent_acc = np.mean( self.agent_memory['accuracy'][-self.recent_zone:]) return recent_acc, recent_reward # if __name__ == '__main__': api = Baidu() rm = ResultManager('evaluation_results') running_agent = RunningAgent( dqn_path='evaluation_results/agent_DQN_train_baidu_imagenet.h5', banchmark_q=75, cloud_backend=api, ) imagenet_paths = _gen_sample_set_imagenet( '/home/hsli/gnode02/imagenet-data/train/', 3)[-500:] test_image_paths = imagenet_paths for idx, path in enumerate(test_image_paths): error_code, log_dict = running_agent.agent_upload(path)
x = feature_extractor.output x = AveragePooling2D(pool_size=(4, 4))(x) feature_extractor = Model(inputs=feature_extractor.input, outputs=x) compute_memory(101) # agent agent = DQN_Agent(s_dim=1280, a_dim=10, epsilon_decay=0.99, epsilon_min=0.02, gamma=0.95, replay_batchsize=256) if __name__ == '__main__': test_image_paths = imagenet_paths[:5] # FLIR[:1000] # test_image_paths = FLIR[:1000] cloud_agent = Baidu() train_log = defaultdict(list) ref_results = defaultdict(dict) compress_results = defaultdict(dict) choose_action_total_time = 0 feedback_total_time = 0 feature_total_time = 0 recent_accuracy = 0 recent_reward = 0 start_time = time.time() if EVALUATION: agent.model = load_model('compute_time_results/baidu_imagenet.h5') # agent.model = load_model('compute_time_results/baidu_FLIR.h5')