How to train your own object detection models using the TensorFlow Object Detection API (2020 Update)
This started as a summary of this nice tutorial, but has since then become its own thing.
import matplotlib.pyplot as plt | |
import numpy as np | |
def show_images(images, cols = 1, titles = None): | |
"""Display a list of images in a single figure with matplotlib. | |
Parameters | |
--------- | |
images: List of np.arrays compatible with plt.imshow. | |
This started as a summary of this nice tutorial, but has since then become its own thing.
# MIT License | |
# | |
# Copyright (c) 2018 Stefano Nardo https://gist.github.com/stefanonardo | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
import pandas as pd | |
import numpy as np | |
from lxml import etree | |
import xmlAnnotation.etree.cElementTree as ET | |
fields = ['NAME_ID', 'XMIN', 'YMIN', 'W', 'H', 'XMAX', 'YMAX'] | |
df = pd.read_csv('loose_bb_test.csv', usecols=fields) | |
# Change the name of the file. |
# Assume labels is a possibly multidimensional array of categories / token indices | |
_, label_counts = np.unique(labels, axis=None, return_counts=True) # Will flatten multidimensional arrays | |
# For multi-label classification you should normalize by the number of samples instead | |
label_frequencies = label_counts.astype(np.float) / np.sum(label_counts) | |
label_logprobs = np.log(label_frequencies) | |
# Now you just need to assign the values in label_logprobs to your bias vector! |