Beispiel #1
0
    def parse_get_user_friends2(self, result):
        friends = result["friends"]
        categories = result["categories"]
        info = result["info"]
        marknames = result["marknames"]
        vipinfo = result["vipinfo"]

        ret_friends = {}
        ret_categories = []

        # parse categories info
        for categorie in categories:
            categorie_obj = Categories()
            categorie_obj.index = categorie["index"]
            categorie_obj.name = categorie["name"]
            categorie_obj.sort = categorie["sort"]
            ret_categories.append(categorie_obj)

        # parse friends
        for i in range(0, len(friends)):
            friend_obj = Friend()
            friend_obj.friends_flag = friends[i]["flag"]
            friend_obj.friends_categories = friends[i]["categories"]

            ret_friends[friends[i]["uin"]] = friend_obj

        # parse info
        for i in range(0, len(info)):
            friend_obj = ret_friends[info[i]["uin"]]
            friend_obj.info_face = info[i]["face"]
            friend_obj.info_flag = info[i]["flag"]
            friend_obj.info_nick = info[i]["nick"]

        # parse marknames
        for i in range(0, len(marknames)):
            friend_obj = ret_friends[marknames[i]["uin"]]
            friend_obj.marknames_markname = marknames[i]["markname"]
            friend_obj.marknames_type = marknames[i]["type"]

        # parse vipinfo
        for i in range(0, len(vipinfo)):
            friend_obj = ret_friends[vipinfo[i]["u"]]
            friend_obj.vip_info["level"] = vipinfo[i]["vip_level"]
            friend_obj.vip_info["is_vip"] = vipinfo[i]["is_vip"]

        return ret_friends, ret_categories
def categorize_image(image: ImageModel) -> Categories:
    """Categorize an image into multiple product categories using TensorFlow.

    Args:
        image (ImageModel): Base64 encoded JPG image

    Raises:
        HTTPException: Request could not be processed (e.g. wrong image format)

    Returns:
        Categories: Identified labels
    """
    try:
        # get base64 encoded image transformed
        image = util.decode_img(image.image)

        predictions = model.predict(image)
        predictions = util.transform_predictions(predictions)
        predictions = encoder.inverse_transform(predictions)

        return Categories(categories=predictions[0])
    except Exception as e:
        raise HTTPException(400)
 def put(self, categoryID):
     return Categories.changeCategoryName(self, categoryID)
 def delete(self, categoryID):
     return Categories.deleteSingleCategory(self, categoryID)
 def get(self, categoryID):
     return Categories.getSingleCategory(self, categoryID)
 def post(self):
     return Categories.createCategory(self)
 def get(self):
     return Categories.getAllCategories(self)