Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import glob
  2. import os
  3. import json
  4.  
  5. # Data
  6. keypoints = [
  7. "Point 1",
  8. "Point 2"
  9. ]
  10.  
  11. keypoints_style = [
  12. "#00FF00",
  13. "#00FFFF"
  14. ]
  15.  
  16. ellipses = [
  17. "Ellipse 1",
  18. "Ellipse 2"
  19. ]
  20.  
  21. ellipses_style = [
  22. "#FF00FF",
  23. "#FFFF00",
  24. ]
  25.  
  26. categories = [{
  27. "id" : "0",
  28. "name" : "black mouse",
  29. "supercategory" : "mouse",
  30. "keypoints" : keypoints,
  31. "keypoints_style" : keypoints_style,
  32. "ellipses": ellipses,
  33. "ellipses_style": ellipses_style,
  34. },
  35. {
  36. "id" : "1",
  37. "name" : "white mouse",
  38. "supercategory" : "mouse",
  39. "keypoints" : keypoints,
  40. "keypoints_style" : keypoints_style,
  41. "ellipses": ellipses,
  42. "ellipses_style": ellipses_style,
  43. }]
  44.  
  45.  
  46. image_dir_regx = '/home/lunarian/dev/personal/annotation_tools/local/mice/*.jpg'
  47. images = []
  48. for image_path in glob.glob(image_dir_regx):
  49. image_file_name = os.path.basename(image_path)
  50. image_id = os.path.splitext(image_file_name)[0]
  51. image_url = "http://localhost:6008/" + image_file_name
  52. images.append({
  53. "id" : image_id,
  54. "file_name" : image_file_name,
  55. "url" : image_url
  56. })
  57.  
  58.  
  59. dataset = {
  60. "categories" : categories,
  61. "images" : images,
  62. "annotations" : [],
  63. "licenses" : []
  64. }
  65.  
  66. dataset_file_path = "local/datasets/mouse_dataset.json"
  67. with open(dataset_file_path, 'w') as f:
  68. json.dump(dataset, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement