Last active
July 29, 2020 05:25
-
-
Save Praveen76/3a10586da18dcf286d2e0309a637b985 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
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 | |
#Read all pdf files in images and then in text and store that in temp folder | |
for file in allfiles: | |
#print(file) | |
if (file.split(".")[1]=='xml'): | |
fileName='C:/Users/PraveenKumar/RetinaNet/maskDetectorJPEGImages/'+file.replace(".xml",'.jpg') | |
tree = ET.parse(annotPath+file) | |
root = tree.getroot() | |
for obj in root.iter('object'): | |
cls_name = obj.find('name').text | |
xml_box = obj.find('bndbox') | |
xmin = xml_box.find('xmin').text | |
ymin = xml_box.find('ymin').text | |
xmax = xml_box.find('xmax').text | |
ymax = xml_box.find('ymax').text | |
# Append rows in Empty Dataframe by adding dictionaries | |
data = data.append({'fileName': fileName, 'xmin': xmin, 'ymin':ymin,'xmax':xmax,'ymax':ymax,'class':cls_name}, ignore_index=True) | |
data.shape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment