Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import os | |
print(os.getcwd()) | |
git clone https://github.com/fizyr/keras-retinanet.git | |
%cd keras-retinanet/ | |
!pip install . | |
!python setup.py build_ext --inplace |
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
import os | |
print(os.getcwd()) | |
git clone https://github.com/fizyr/keras-retinanet.git | |
%cd keras-retinanet/ | |
!pip install . | |
!python setup.py build_ext --inplace |
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
import numpy as np | |
import shutil | |
import pandas as pd | |
import os, sys, random | |
import xml.etree.ElementTree as ET | |
import pandas as pd | |
from os import listdir | |
from os.path import isfile, join | |
import matplotlib.pyplot as plt | |
from PIL import Image |
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
pngPath='C:/Users/PraveenKumar/RetinaNet//maskDetectorJPEGImages/' | |
annotPath='C:/Users/PraveenKumar/RetinaNet//maskDetectorXMLfiles/' | |
data=pd.DataFrame(columns=['fileName','xmin','ymin','xmax','ymax','class']) | |
os.getcwd() | |
#read All files | |
allfiles = [f for f in listdir(annotPath) if isfile(join(annotPath, f))] | |
#Read all pdf files in images and then in text and store that in temp folder |
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
# pick a random image | |
filepath = df.sample()['fileName'].values[0] | |
# get all rows for this image | |
df2 = df[df['fileName'] == filepath] | |
im = np.array(Image.open(filepath)) | |
# if there's a PNG it will have alpha channel | |
im = im[:,:,:3] |
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
#Define labels & write them in a file | |
classes = ['mask','noMask'] | |
with open('../maskDetectorClasses.csv', 'w') as f: | |
for i, class_name in enumerate(classes): | |
f.write(f'{class_name},{i}\n') | |
if not os.path.exists('snapshots'): | |
os.mkdir('snapshots') |
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
URL_MODEL = 'https://github.com/fizyr/keras-retinanet/releases/download/0.5.1/resnet50_coco_best_v2.1.0.h5' | |
urllib.request.urlretrieve(URL_MODEL, PRETRAINED_MODEL) | |
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
#Put your training data path & file that has labels for your training data | |
!keras_retinanet/bin/train.py | |
--freeze-backbone | |
--random-transform | |
--weights {PRETRAINED_MODEL} | |
--batch-size 8 | |
--steps 500 | |
--epochs 15 | |
csv maskDetectorData.csv | |
maskDetectorClasses.csv |
OlderNewer