MCPcopy Create free account
hub / github.com/Duankaiwen/CenterNet / loadNumpyAnnotations

Method loadNumpyAnnotations

data/coco/PythonAPI/pycocotools/coco.py:382–403  ·  view source on GitHub ↗

Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} :param data (numpy.ndarray) :return: annotations (python nested list)

(self, data)

Source from the content-addressed store, hash-verified

380 print('downloaded {}/{} images (t={:0.1f}s)'.format(i, N, time.time()- tic))
381
382 def loadNumpyAnnotations(self, data):
383 """
384 Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class}
385 :param data (numpy.ndarray)
386 :return: annotations (python nested list)
387 """
388 print('Converting ndarray to lists...')
389 assert(type(data) == np.ndarray)
390 print(data.shape)
391 assert(data.shape[1] == 7)
392 N = data.shape[0]
393 ann = []
394 for i in range(N):
395 if i % 1000000 == 0:
396 print('{}/{}'.format(i,N))
397 ann += [{
398 'image_id' : int(data[i, 0]),
399 'bbox' : [ data[i, 1], data[i, 2], data[i, 3], data[i, 4] ],
400 'score' : data[i, 5],
401 'category_id': int(data[i, 6]),
402 }]
403 return ann
404
405 def annToRLE(self, ann):
406 """

Callers 1

loadResMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected