Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. # Import necessary libraries
  2. import os
  3. import json
  4. import string
  5. import pandas as pd
  6. import turicreate as tc
  7.  
  8. # Enable the ability to view images in a cell
  9. %matplotlib inline
  10.  
  11. # Helper function that will build our bounding boxes in a way that TuriCreate can work with
  12. def build_annotations(_tuple):
  13. label = _tuple[0];
  14. x_min = _tuple[1][0]; # left x
  15. x_max = _tuple[1][2]; # right x
  16. y_min = _tuple[1][1]; # top y
  17. y_max = _tuple[1][3]; # bottom y
  18.  
  19. ret = {"coordinates":
  20. {
  21. "x" : (x_min + x_max)/2,
  22. "y" : (y_min + y_max)/2,
  23. "width": x_max - x_min,
  24. "height": y_max - y_min
  25. },
  26. "label": label
  27. }
  28. return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement