Add object detection script 27/260127/2
authorKwang Son <k.son@samsung.com>
Mon, 21 Jun 2021 03:09:14 +0000 (12:09 +0900)
committerkwang son <k.son@samsung.com>
Mon, 21 Jun 2021 07:57:00 +0000 (07:57 +0000)
Change-Id: I50d3708cdfac0547064ac3bae55238a321d27a09
Signed-off-by: Kwang Son <k.son@samsung.com>
script/mvqa/db.py

index 52d420c..9190239 100644 (file)
@@ -16,6 +16,7 @@ testset = [('barcode detect',),
            ('facedetection(cascade) - CPU',),
            ('facedetection(TFlite, mobilenetv1ssd) - CPU',),
            ('imageclassification(TFlite, mobilenetv1) - CPU',),
+           ('objectdetection(TFlite, efficientdet) - CPU(QUANT)',),
            ]
 
 
@@ -268,6 +269,38 @@ class ImageClassification(Session):
         os.system('rm ' + file_path)
 
 
+class ObjectDetection(Session):
+    def __init__(self, dataset_id, testset_id):
+        super().__init__(dataset_id, testset_id)
+
+    def load(self, item):
+        file_path = os.path.basename(item)
+        os.system(self.remote_db + item)
+        os.system('sdb push ' + file_path + ' ' +
+                  os.path.join(self.work_dir, file_path))
+
+    def run(self, item):
+        file_path = os.path.basename(item)
+        command = '2\n7\n1\n8\n1\n9\n' + \
+            os.path.join(self.work_dir, file_path) + '\n2\n2\n'
+        subp = subprocess.run(['sdb', 'shell', 'mv_infer_test_suite'],
+                              stdout=subprocess.PIPE, input=command.encode('UTF-8'))
+        return subp.stdout
+
+    def verify(self, result, label):
+        rv = result.decode('utf-8')
+        trunk = rv[rv.find('callback:'):]
+        time_target = 'time : '
+        task_time = trunk[trunk.find(
+            time_target) + len(time_target): trunk.find('(ms)')]
+        return (task_time, trunk[:trunk.find('(ms)')])
+
+    def clean(self, item):
+        file_path = os.path.basename(item)
+        os.system('sdb shell rm ' + os.path.join(self.work_dir, file_path))
+        os.system('rm ' + file_path)
+
+
 def get_session(dataset_id, testset_id):
     if(dataset_id == 1):
         return Barcode(dataset_id, testset_id)
@@ -278,5 +311,7 @@ def get_session(dataset_id, testset_id):
             return FaceDetectionTFlite(dataset_id, testset_id)
     elif(dataset_id == 3):
         return ImageClassification(dataset_id, testset_id)
+    elif(dataset_id == 4):
+        return ObjectDetection(dataset_id, testset_id)
     else:
         raise NotImplementedError