def calculate_score_for_each_mood(self):
    '\n        利用谷歌nima模型对图片进行评分\n        paper: https://arxiv.org/abs/1709.05424\n        pytorch model: https://github.com/truskovskiyk/nima.pytorch.git\n\n        计算每条说说中图片的平均分\n        对于没有图片的按均值进行填充\n        :return:\n        '
    self.IMAGE_SCORE_FILE_PATH = '/Users/maicius/code/nima.pytorch/nima/result_dict.json'
    with open(self.IMAGE_SCORE_FILE_PATH, 'r', encoding='utf-8') as r:
        self.image_score_dict = json.load(r)
    self.image_score_df = pd.DataFrame(self.image_score_dict)
    mean_score = self.image_score_df[(self.image_score_df['score'] != (- 1))].mean()[0]
    self.image_score_df.loc[((self.image_score_df.score == (- 1)), 'score')] = mean_score
    tid_list = self.mood_data_df['tid'].values
    for tid in tid_list:
        scores = self.image_score_df[self.image_score_df.image.str.contains(tid)].score
        if (len(scores) > 0):
            self.mood_data_df.loc[((self.mood_data_df.tid == tid), 'score')] = round(scores.mean(), 2)
    self.mood_data_df.fillna(mean_score)
    print('score shape:', self.mood_data_df.shape)
    self.mood_data_df.to_csv(self.MOOD_DATA_SCORE_FILE_NAME)
利用谷歌nima模型对图片进行评分
paper: https://arxiv.org/abs/1709.05424
pytorch model: https://github.com/truskovskiyk/nima.pytorch.git

计算每条说说中图片的平均分
对于没有图片的按均值进行填充
:return:
def calculate_score_for_each_mood(self):
    '\n        利用谷歌nima模型对图片进行评分\n        paper: https://arxiv.org/abs/1709.05424\n        pytorch model: https://github.com/truskovskiyk/nima.pytorch.git\n\n        计算每条说说中图片的平均分\n        对于没有图片的按均值进行填充\n        :return:\n        '
    self.IMAGE_SCORE_FILE_PATH = '/Users/maicius/code/nima.pytorch/nima/result_dict.json'
    with open(self.IMAGE_SCORE_FILE_PATH, 'r', encoding='utf-8') as r:
        self.image_score_dict = json.load(r)
    self.image_score_df = pd.DataFrame(self.image_score_dict)
    mean_score = self.image_score_df[(self.image_score_df['score'] != (- 1))].mean()[0]
    self.image_score_df.loc[((self.image_score_df.score == (- 1)), 'score')] = mean_score
    tid_list = self.mood_data_df['tid'].values
    for tid in tid_list:
        scores = self.image_score_df[self.image_score_df.image.str.contains(tid)].score
        if (len(scores) > 0):
            self.mood_data_df.loc[((self.mood_data_df.tid == tid), 'score')] = round(scores.mean(), 2)
    self.mood_data_df.fillna(mean_score)
    print('score shape:', self.mood_data_df.shape)
    self.mood_data_df.to_csv(self.MOOD_DATA_SCORE_FILE_NAME)