-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadInData.py
More file actions
53 lines (34 loc) · 1.24 KB
/
readInData.py
File metadata and controls
53 lines (34 loc) · 1.24 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
from skimage import io
import json
import urllib
from urllib.request import urlretrieve # Python 3
import csv
#This
img = io.imread("/Users/thomasbekman/Documents/ForChase/test.jpg")
#First step pull down all the files from the .json
josn_path = "/Users/thomasbekman/Documents/Homework/Deep_Learning/Final_Project/Final/Forest_FIre.json"
#print(type(img))
image = []
for line in open('/Users/thomasbekman/Documents/Homework/Deep_Learning/Final_Project/Final/Forest_FIre.json', 'r'):
image.append(json.loads(line))
with open('labels1.csv', 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
labels = []
count = 0
for i in image:
label = i["annotation"]["labels"]
link = i["content"]
print(label)
try:
if(label[0] != 'garbage'):
count += 1
urlretrieve(link, "images/"+str(count)+".jpg")
rowToWrite = []
rowToWrite.append(str(count))
rowToWrite.append(label[0])
print(rowToWrite)
spamwriter.writerow(rowToWrite)
#print(label[0])
except:
print("Failed")