async def dogs(**kwargs):
    log.debug("dogs({})".format(kwargs))
    model = kwargs.get("model", "ResNet18")
    map_names = dogs_map_names
    img_path = kwargs.get("img_path", None)
    if img_path is None:
        raise InvalidParams("\"img_path\" is required")
    image_dims = (3, 224, 224)

    result = img_recon.image_recognition("dogs", model, map_names, img_path, image_dims)
    return {"result": result}
Beispiel #2
0
    def cars(self, request, context):

        self.img_path = request.img_path
        self.model = request.model

        map_names = cars_map_names
        image_dims = (3, 224, 224)
        json_result = img_recon.image_recognition("cars", self.model,
                                                  map_names, self.img_path,
                                                  image_dims)

        self.result = Result()
        self.result.top_5 = str(json_result["top_5"]).encode("utf-8")
        self.result.delta_time = str(json_result["delta_time"]).encode("utf-8")
        log.debug("cars({},{})={}".format(self.model, self.img_path,
                                          self.result.top_5))
        return self.result
Beispiel #3
0
    def flowers(self, request, context):
        # In our case, request is a Numbers() object (from .proto file)
        self.img_path = request.img_path
        self.model = request.model

        map_names = flowers_map_names
        image_dims = (3, 224, 224)
        json_result = img_recon.image_recognition("flowers", self.model,
                                                  map_names, self.img_path,
                                                  image_dims)

        # To respond we need to create a Result() object (from .proto file)
        self.result = Result()
        self.result.top_5 = str(json_result["top_5"]).encode("utf-8")
        self.result.delta_time = str(json_result["delta_time"]).encode("utf-8")
        log.debug("flowers({},{})={}".format(self.model, self.img_path,
                                             self.result.top_5))
        return self.result
    def dogs(self, request, context):

        self.img_path = request.img_path
        self.model = request.model

        map_names = dogs_map_names
        image_dims = (3, 224, 224)
        json_result = img_recon.image_recognition("dogs", self.model,
                                                  map_names, self.img_path,
                                                  image_dims)

        # To respond we need to create a Output() object (from .proto file)
        self.response = Output()
        self.response.top_5 = str(json_result["top_5"]).encode("utf-8")
        self.response.delta_time = str(
            json_result["delta_time"]).encode("utf-8")
        log.debug("dogs({},{})={}".format(self.model, self.img_path,
                                          self.response.top_5))
        return self.response
Beispiel #5
0
def mp_image_recognition(method, request, map_names, image_dims, return_dict):
    import service.image_recon as img_recon
    return_dict["response"] = img_recon.image_recognition(
        method, request.model, map_names, request.img_path, image_dims)