Created
November 30, 2018 05:06
-
-
Save salman-ghauri/7c09137671928e935c81474cbf351d50 to your computer and use it in GitHub Desktop.
Data parsing on Open Images v4 to speed things "https://towardsdatascience.com/faster-r-cnn-object-detection-implemented-by-keras-for-custom-data-from-googles-open-images-125f62b9141a"
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
s = class_descriptions[class_descriptions['class']\ | |
.isin(classes)]\ | |
.set_index('name').T.to_dict() | |
train_df = pd.DataFrame(columns=['FileName', 'XMin', 'XMax', | |
'YMin', 'YMax', | |
'ClassName']) | |
# Find boxes in each image and put them in a dataframe | |
train_imgs = os.listdir(train_path) | |
train_imgs = [name[0:16] for name in train_imgs\ | |
if not name.startswith('.')] | |
df = annotations_bbox[annotations_bbox.ImageID\ | |
.isin(train_imgs)] | |
df = df[df.LabelName.isin(label_names)] | |
dd = df.groupby("ImageID") | |
for ii in train_imgs: | |
cc = dd.get_group(ii) | |
for index, row in cc.iterrows(): | |
train_df = train_df.append({'FileName': '{}.jpg'\ | |
.format(ii), | |
'XMin': row['XMin'], | |
'XMax': row['XMax'], | |
'YMin': row['YMin'], | |
'YMax': row['YMax'], | |
'ClassName': \ | |
s[row['LabelName']]['class']}, | |
ignore_index=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment