In [1]:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
In [2]:
# get all the keys
annotation = np.load("DATA/annotation_list.npy")[()]
In [5]:
image_list = annotation.keys()
image_list
Out[5]:
['2009_000080',
'2009_004099',
'2010_005482',
'2010_000948',
'2008_004688',
'2008_006175',
'2010_003527',
'2010_004891',
'2008_006068',
'2008_004155',
'2010_004954',
'2010_000175',
'2010_005551',
'2010_002255',
'2008_006285',
'2008_006576',
'2010_002316',
'2010_002098',
'2010_000586',
'2008_004257',
'2008_007256',
'2008_006307',
'2010_000683',
'2009_000466',
'2010_000409',
'2008_000793',
'2009_002527',
'2009_000013',
'2010_004829',
'2008_003167',
'2010_005250',
'2010_002676',
'2008_004967',
'2008_006377',
'2010_002678',
'2009_002898',
'2010_004120',
'2010_004691',
'2008_004873',
'2009_001016',
'2008_005288',
'2010_001382',
'2010_005806',
'2010_001417',
'2009_002061',
'2010_002876',
'2010_003275',
'2008_005574',
'2009_000304',
'2010_002224',
'2009_003904',
'2008_005270',
'2009_002592',
'2009_001906',
'2010_001125',
'2010_001656',
'2010_002963',
'2009_003201',
'2008_006480',
'2010_002512',
'2011_001900',
'2010_005938',
'2010_003579',
'2009_004841',
'2010_003805',
'2010_003800',
'2010_004515',
'2008_004538',
'2011_001441',
'2009_005219',
'2008_003239',
'2009_005211',
'2008_005550',
'2010_003988',
'2008_001290',
'2010_002422',
'2010_002354',
'2008_001350',
'2010_002587',
'2008_005699',
'2010_003971',
'2010_003976',
'2008_006347',
'2008_006341',
'2008_006656',
'2008_007548',
'2009_004796',
'2010_000442',
'2010_004861',
'2008_000115',
'2008_000116',
'2008_000056',
'2010_003467',
'2008_007324',
'2010_001452',
'2008_003499',
'2010_005115',
'2009_002363',
'2008_005777',
'2008_007269',
'2009_000862',
'2010_005709',
'2008_005977',
'2009_002141',
'2009_000342',
'2009_003415',
'2009_004038',
'2010_004768',
'2008_005235',
'2011_001116',
'2008_005337',
'2008_003052',
'2011_000426',
'2010_005208',
'2010_001333',
'2010_001331',
'2008_007216',
'2009_004607',
'2010_002645',
'2008_002293',
'2010_004545',
'2010_001516',
'2008_002298',
'2009_005033',
'2011_002276',
'2009_002739',
'2009_004210',
'2008_007632',
'2008_005480',
'2008_001640',
'2008_006967',
'2008_004579',
'2011_000165',
'2011_000162',
'2010_001587',
'2010_000118',
'2010_003943',
'2008_005469',
'2009_003528',
'2010_004335',
'2009_001227',
'2010_003497',
'2008_005460',
'2011_001568',
'2008_000950',
'2008_007964',
'2010_002789',
'2010_002543',
'2009_004504',
'2008_003932',
'2008_006765',
'2008_005061',
'2010_003427',
'2010_003781',
'2010_004425',
'2008_007662',
'2008_007494',
'2008_003088',
'2010_001863',
'2010_000647',
'2008_007794',
'2008_004006',
'2008_001513',
'2010_002303',
'2011_001841',
'2008_007404',
'2008_007403',
'2010_002307',
'2010_002305',
'2010_000724',
'2010_005230',
'2009_000511',
'2010_005239',
'2010_003232',
'2009_003457',
'2008_005309',
'2009_001419',
'2008_001885',
'2009_001126',
'2009_001411',
'2010_002602',
'2008_007702',
'2009_004721',
'2010_002763',
'2008_002152',
'2008_007130',
'2008_001111',
'2009_001008',
'2008_005805',
'2010_005833',
'2008_002766',
'2010_002845',
'2010_002771',
'2008_000839',
'2008_005566',
'2009_000681',
'2008_003704',
'2010_004753',
'2008_004189',
'2010_004209',
'2011_000419',
'2010_001468',
'2010_003861',
'2010_000737',
'2010_003863',
'2009_003070',
'2008_005421',
'2009_005299',
'2010_004479',
'2011_000634',
'2010_005021',
'2010_002504',
'2010_005903',
'2010_003190',
'2008_000581',
'2010_003468',
'2008_004540',
'2009_004382',
'2008_000464',
'2008_005510',
'2010_004037',
'2008_005109',
'2010_003299',
'2010_005456',
'2009_003771',
'2009_000614',
'2010_000218',
'2010_000602',
'2008_005735',
'2010_001827',
'2010_001737',
'2008_007855',
'2010_004286',
'2010_001637',
'2008_004048',
'2008_007914',
'2008_002234',
'2010_003687',
'2010_002025',
'2010_006011',
'2010_002348',
'2011_001601',
'2011_001607',
'2009_000330',
'2009_001361',
'2009_002228',
'2011_001597',
'2008_004640',
'2009_003312',
'2010_001913',
'2008_006863',
'2011_000229',
'2008_006956',
'2009_004448',
'2010_002723',
'2008_007989',
'2009_003380',
'2010_001351',
'2010_005712',
'2010_001291',
'2010_001292',
'2010_003223',
'2011_003166',
'2009_003955',
'2008_006817',
'2008_007187',
'2009_001522',
'2008_002597',
'2009_004940',
'2010_000172',
'2010_004023',
'2008_002681',
'2010_001070',
'2010_005006',
'2008_002045',
'2008_003607',
'2010_005394',
'2011_001775',
'2008_001792',
'2009_000249',
'2008_006609',
'2008_005252',
'2010_004157',
'2010_004257',
'2010_000317',
'2010_003898',
'2010_004320',
'2008_006781',
'2009_000716',
'2009_001623',
'2010_003488',
'2010_002479',
'2008_000345',
'2010_005899',
'2008_003519',
'2010_006058',
'2008_005072',
'2010_003823',
'2011_000824',
'2008_000306',
'2010_000497',
'2010_000553',
'2010_000552',
'2011_002128',
'2011_002685',
'2009_003626',
'2010_000791',
'2009_000782',
'2008_003772',
'2008_004374',
'2010_003675',
'2008_001078',
'2008_001374',
'2010_006025',
'2009_001391',
'2010_005592',
'2010_005222',
'2008_006325',
'2010_005185',
'2008_000670',
'2009_000566',
'2008_004736',
'2009_001562',
'2010_002192',
'2009_003698',
'2010_002448',
'2008_001433',
'2011_002631',
'2008_007736',
'2009_004655',
'2009_002268',
'2009_000966',
'2009_002667',
'2009_000964',
'2008_006520',
'2010_005508',
'2008_004933',
'2008_002004',
'2008_005816',
'2010_005763',
'2009_004307',
'2009_000284',
'2010_002993',
'2008_005181',
'2010_003358',
'2008_006218',
'2009_000366',
'2010_004585',
'2010_001089',
'2008_004422',
'2010_004667',
'2009_003847',
'2010_004743',
'2008_000182',
'2010_005344',
'2010_005340',
'2010_002531',
'2010_002533',
'2008_003557',
'2011_001292',
'2009_005119',
'2008_000222',
'2008_008585',
'2010_003451',
'2010_003758',
'2011_002916',
'2008_002201',
'2010_001030',
'2010_004104',
'2008_002410',
'2010_000261',
'2009_004971',
'2011_002004',
'2008_002682',
'2010_002406',
'2008_003420',
'2010_000291',
'2009_001198',
'2010_003133',
'2009_003143',
'2011_001264',
'2008_006746',
'2010_004369',
'2008_005003',
'2010_000468',
'2009_000955',
'2010_005143',
'2011_000813',
'2009_000488',
'2009_002267',
'2010_000506',
'2009_004128',
'2010_001968',
'2009_003718',
'2008_003104',
'2010_000665',
'2010_002710',
'2010_002713',
'2008_006449',
'2008_004290',
'2009_004456',
'2008_006113',
'2010_002086',
'2008_007164',
'2008_005857',
'2010_005647',
'2009_000002',
'2011_002699',
'2009_004150',
'2009_004157',
'2010_004815',
'2010_002146',
'2008_007888',
'2010_001215',
'2008_000401',
'2010_005264',
'2010_002900',
'2008_006362',
'2010_000163',
'2009_005158',
'2011_000661',
'2010_005035',
'2010_005048',
'2010_004681',
'2011_002409',
'2009_002753',
'2009_002053',
'2008_000853',
'2011_001390',
'2010_003240',
'2008_002623',
'2010_003249',
'2010_005082',
'2010_004634',
'2008_007086',
'2010_004141',
'2010_001147',
'2010_001783',
'2010_000712',
'2010_003966',
'2010_001787',
'2008_007176',
'2010_004457',
'2009_004529',
'2008_000358',
'2011_001911',
'2010_001544',
'2009_001094',
'2010_000828',
'2010_003402',
'2009_004248',
'2010_005886',
'2010_001149',
'2011_000780',
'2010_003764',
'2011_000789',
'2009_002008',
'2011_002883',
'2010_000001',
'2010_003641',
'2008_005614',
'2010_004584',
'2009_001484',
'2011_001534',
'2009_002836',
'2009_002837',
'2009_001279',
'2009_002936',
'2010_001712',
'2008_003228',
'2010_002693',
'2011_003211',
'2008_004347',
'2010_005425',
'2010_005421',
'2010_002366',
'2010_002040',
'2008_006403',
'2008_002845',
'2010_003067',
'2009_002470',
'2009_002673',
'2008_000660',
'2010_000536',
'2009_004051',
'2008_000062',
'2010_005697',
'2010_001938',
'2008_004119',
'2008_006793',
'2010_002965',
'2010_000941',
'2008_001210',
'2010_005108',
'2010_002000',
'2010_005853',
'2008_007059',
'2008_005943',
'2010_005287',
'2010_000996',
'2011_001128',
'2008_004797',
'2009_004022',
'2008_003045',
'2008_007610',
'2010_002138',
'2010_005606',
'2010_002137',
'2010_004415',
'2009_001835',
'2010_000054',
'2010_001057',
'2010_004553',
'2009_001057',
'2011_001620',
'2008_002899',
'2008_007327',
'2008_003624',
'2009_002499',
'2008_006999',
'2010_000099',
'2010_000692',
'2010_001021',
'2008_005657',
'2009_003655',
'2009_005083',
'2010_000374',
'2009_003129',
'2010_000875',
'2010_001754',
'2008_003343',
'2008_006690',
'2010_001534',
'2008_006190',
'2010_005973',
'2008_001004',
'2008_006050',
'2010_003569',
'2008_000536',
'2009_004291',
'2010_002167',
'2010_003928',
'2009_003013',
'2009_001931']
In [6]:
# get a viusalization
imgfile = "2009_000080"
img = plt.imread("DATA/{}.jpg".format(imgfile))
box = annotation[imgfile]
print box
# Create figure and axes
fig,ax = plt.subplots(1)
ax.imshow(img)
for eachbox in box:
cx, cy, w, h = eachbox
# Create a Rectangle patch
rect = patches.Rectangle((cx-w/2,cy-h/2),w,h,linewidth=1,edgecolor='r',facecolor='none')
# Add the patch to the Axes
ax.add_patch(rect)
plt.show()
print "The box is {}".format(box)
print "image size is {}".format(img.shape)
centerx, centery, w,h
[[211.0, 166, 232, 259]]
The box is [[211.0, 166, 232, 259]]
image size is (375, 500, 4)
In [ ]:
In [ ]:
In [ ]:
Content source: BitTiger-MP/DS502-AI-Engineer
Similar notebooks: