Commit 763159f7 authored by 赵威's avatar 赵威

predict with city

parent 6d269ab7
from utils.cache import redis_client4
import tensorflow as tf
from main_portrait import offline_predict_diary, offline_predict_tractate
from models.esmm.fe import device_fe, diary_fe, tractate_fe
from utils.cache import get_essm_model_save_path, redis_client4
def predict_with_city_changed():
def predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn):
key = "doris:user_portrait:city_changed:device:queue"
total = redis_client4.llen(key)
while (total > 0):
device_id = redis_client4.lpop(key)
print(device_id)
device_id = str(device_id, "utf-8")
offline_predict_diary(device_id, device_dict, diary_dict, diary_predict_fn)
offline_predict_tractate(device_id, device_dict, tractate_dict, tractate_predict_fn)
print("=========================================\n")
if __name__ == "__main__":
predict_with_city_changed()
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.INFO)
device_dict = device_fe.get_device_dict_from_redis()
diary_dict = diary_fe.get_diary_dict_from_redis()
tractate_dict = tractate_fe.get_tractate_dict_from_redis()
print("redis data: " + str(len(device_dict)) + " " + str(len(diary_dict)) + " " + str(len(tractate_dict)))
diary_save_path = get_essm_model_save_path("diary")
if not diary_save_path:
diary_save_path = "/home/gmuser/data/models/diary/1597050209"
print(diary_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
diary_predict_fn = tf.contrib.predictor.from_saved_model(diary_save_path)
tractate_save_path = get_essm_model_save_path("tractate")
if not tractate_save_path:
tractate_save_path = "/home/gmuser/data/models/tractate/1596509299"
print(tractate_save_path + "!!!!!!!!!!!!!!!!!!!!!!!!!!!")
tractate_predict_fn = tf.contrib.predictor.from_saved_model(tractate_save_path)
predict_with_city_changed(device_dict, diary_dict, tractate_dict, diary_predict_fn, tractate_predict_fn)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment