()
| 23 | |
| 24 | |
| 25 | def download(): # download tiger and kittycat image |
| 26 | categories = ['tiger', 'kittycat'] |
| 27 | for category in categories: |
| 28 | os.makedirs('./for_transfer_learning/data/%s' % category, exist_ok=True) |
| 29 | with open('./for_transfer_learning/imagenet_%s.txt' % category, 'r') as file: |
| 30 | urls = file.readlines() |
| 31 | n_urls = len(urls) |
| 32 | for i, url in enumerate(urls): |
| 33 | try: |
| 34 | urlretrieve(url.strip(), './for_transfer_learning/data/%s/%s' % (category, url.strip().split('/')[-1])) |
| 35 | print('%s %i/%i' % (category, i, n_urls)) |
| 36 | except: |
| 37 | print('%s %i/%i' % (category, i, n_urls), 'no image') |
| 38 | |
| 39 | |
| 40 | def load_img(path): |
nothing calls this directly
no outgoing calls
no test coverage detected