Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
computer_science:computer_vision:opencv:object_identification_tensorflow_opencv_imageai_yolo_download_images_script [2020/08/07 16:39] – created carlossousa | computer_science:computer_vision:opencv:object_identification_tensorflow_opencv_imageai_yolo_download_images_script [2023/12/01 12:07] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Python Scripts to Download Images of Hats and People ====== | ||
+ | |||
This is part of the [[: | This is part of the [[: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Download Images of Hats ===== | ||
+ | |||
+ | download_hats_images.py | ||
<code python> | <code python> | ||
Line 15: | Line 23: | ||
os.chdir(' | os.chdir(' | ||
for i in hardhatImages.split(' | for i in hardhatImages.split(' | ||
+ | try: | ||
+ | r = req.get(i, timeout=0.5) | ||
+ | file = i.split("/" | ||
+ | if ' | ||
+ | if len(r.content)> | ||
+ | with open(file, ' | ||
+ | outfile.write(r.content) | ||
+ | noOfImages += 1 | ||
+ | print(' | ||
+ | else: | ||
+ | print(' | ||
+ | else: | ||
+ | print(' | ||
+ | |||
+ | except Exception as e: | ||
+ | print(' | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Download Images of People ===== | ||
+ | |||
+ | download_people_images.py | ||
+ | |||
+ | <code python> | ||
+ | import requests as req | ||
+ | import os as os | ||
+ | |||
+ | peopleLoc = ' | ||
+ | |||
+ | peopleImages = req.get(peopleLoc).text | ||
+ | noOfImages = 0 | ||
+ | |||
+ | if not os.path.exists(' | ||
+ | os.makedirs(' | ||
+ | |||
+ | os.chdir(' | ||
+ | for i in peopleImages.split(' | ||
try: | try: | ||
r = req.get(i, timeout=0.5) | r = req.get(i, timeout=0.5) | ||
Line 33: | Line 81: | ||
print(' | print(' | ||
+ | |||
</ | </ | ||