-
-
Save amankharwal/9a4d7beb4577676b301f2bcb55149d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [] | |
img_size = 124 | |
mask = ['face_with_mask'] | |
non_mask = ["face_no_mask"] | |
labels={'mask':0,'without mask':1} | |
for i in df["name"].unique(): | |
f = i+".json" | |
for j in getJSON(os.path.join(directory,f)).get("Annotations"): | |
if j["classname"] in mask: | |
x,y,w,h = j["BoundingBox"] | |
img = cv2.imread(os.path.join(image_directory,i),1) | |
img = img[y:h,x:w] | |
img = cv2.resize(img,(img_size,img_size)) | |
data.append([img,labels["mask"]]) | |
if j["classname"] in non_mask: | |
x,y,w,h = j["BoundingBox"] | |
img = cv2.imread(os.path.join(image_directory,i),1) | |
img = img[y:h,x:w] | |
img = cv2.resize(img,(img_size,img_size)) | |
data.append([img,labels["without mask"]]) | |
random.shuffle(data) | |
p = [] | |
for face in data: | |
if(face[1] == 0): | |
p.append("Mask") | |
else: | |
p.append("No Mask") | |
sns.countplot(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment