예제 #1
0
 def post(self):
     args = self._parser.parse_args()
     img_bytes = args[IMAGE].stream.read()
     img = sly_image.read_bytes(img_bytes)
     ann = self._model.inference(img,
                                 Annotation(img_size=img.shape[:2]))
     return {ANNOTATION: ann.to_json()}
예제 #2
0
        def post(self):
            args = self._parser.parse_args()
            img_bytes = args[IMAGE].stream.read()
            img = sly_image.read_bytes(img_bytes)

            meta = args[META]
            ann = args[ANNOTATION]
            mode = args[MODE]

            data = {
                "request_type":
                INFERENCE,
                "meta":
                json.loads(meta.stream.read().decode("utf-8"))
                if meta is not None else ProjectMeta().to_json(),
                "annotation":
                json.loads(ann.stream.read().decode("utf-8"))
                if ann is not None else None,
                "mode":
                json.loads(mode.stream.read().decode("utf-8"))
                if mode is not None else {},
                'image_arr':
                img
            }
            return self._model._final_processing(data)
예제 #3
0
 def download_np(self, id):
     '''
     Download image with given id in numpy format
     :param id: int
     :return: image in RGB format(numpy matrix)
     '''
     response = self._download(id)
     img = sly_image.read_bytes(response.content)
     return img
예제 #4
0
 def download_np(self, video_id, frame_index):
     '''
     :param video_id: int
     :param frame_index: int
     :return: image in RGB format(numpy matrix) for frame with given index from given video id
     '''
     response = self._download(video_id, frame_index)
     img = read_bytes(response.content)
     return img
예제 #5
0
 def download_nps(self, dataset_id, ids, progress_cb=None, keep_alpha=False):
     '''
     Doenload images with given ids from dataset with given id in numpy format
     :param dataset_id: int
     :param ids: list of integers
     :param progress_cb:
     :return: list of images in RGB format(numpy matrix)
     '''
     return [sly_image.read_bytes(img_bytes, keep_alpha)
             for img_bytes in self.download_bytes(dataset_id=dataset_id, ids=ids, progress_cb=progress_cb)]
예제 #6
0
    def download_nps(self, dataset_id, ids, progress_cb=None):
        images = []
        if len(ids) == 0:
            return images

        id_to_img = {}
        for img_id, resp_part in self._download_batch(dataset_id, ids):
            id_to_img[img_id] = sly_image.read_bytes(resp_part.content)
            if progress_cb is not None:
                progress_cb(1)

        images = [id_to_img[id] for id in ids]
        return images
예제 #7
0
 def download_np(self, id):
     response = self._download(id)
     img = sly_image.read_bytes(response.content)
     return img
예제 #8
0
 def download_nps(self, dataset_id, ids, progress_cb=None):
     return [
         sly_image.read_bytes(img_bytes)
         for img_bytes in self.download_bytes(
             dataset_id=dataset_id, ids=ids, progress_cb=progress_cb)
     ]
예제 #9
0
 def download_np(self, video_id, frame_index):
     response = self._download(video_id, frame_index)
     img = read_bytes(response.content, input_is_bgr=False)
     return img
예제 #10
0
 def download_np(self, id):
     response = self.download(id)
     image_bytes = np.asarray(bytearray(response.content), dtype="uint8")
     img = image.read_bytes(image_bytes)
     return img