Skip to content

Instantly share code, notes, and snippets.

@sjain07
Last active March 19, 2018 11:25
Show Gist options
  • Save sjain07/91dabdcc185ee40c94423cf3d77c19bc to your computer and use it in GitHub Desktop.
Save sjain07/91dabdcc185ee40c94423cf3d77c19bc to your computer and use it in GitHub Desktop.
image = readImage()
NoOfCells = 7
NoOfClasses = 4
threshold = 0.7
step = height(image)/NoOfCells
prediction_class_array = new_array(size(NoOfCells,NoOfCells,NoOfClasses))
predictions_bounding_box_array = new_array(size(NoOfCells,NoOfCells,NoOfCells,NoOfCells))
final_predictions = []
for (i<0; i<NoOfCells; i=i+1):
for (j<0; j<NoOfCells;j=j+1):
cell = image(i:i+step,j:j+step)
prediction_class_array[i,j] = class_predictor(cell)
predictions_bounding_box_array[i,j] = bounding_box_predictor(cell)
best_bounding_box = [0 if predictions_bounding_box_array[i,j,0, 4] > predictions_bounding_box_array[i,j,1, 4] else 1]
predicted_class = index_of_max_value(prediction_class_array[i,j])
if predictions_bounding_box_array[i,j,best_bounding_box, 4] * max_value(prediction_class_array[i,j]) > threshold:
final_predictions.append([predictions_bounding_box_array[i,j,best_bounding_box, 0:4], predicted_class])
print final_predictions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment