forked from kashyap32/HotDog-Nothotdog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
39 lines (25 loc) · 842 Bytes
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import urllib
import urllib.request
import cv2
import os
import numpy as np
def main():
links = ['LINK of IMAGES']
print (links[0])
paths = 'hotdog'
pic_num = 1
if not os.path.exists(paths):
os.makedirs(paths)
image_urls = str(urllib.request.urlopen(links[0]).read())
print (image_urls)
for i in image_urls.split('\\n'):
try:
urllib.request.urlretrieve(i, paths+"/"+str(pic_num)+".jpg")
img = cv2.imread(paths+"/"+str(pic_num)+".jpg")
if img is not None:
cv2.imwrite(paths+"/"+str(pic_num)+".jpg",img)
pic_num += 1
except Exception as e:
print(str(e))
if __name__ == "__main__":
main()