title: TypeError: string indices must be integers while trying to train MASK_RCNN implementation
body: <p>I've looked at a similar question at  <a href="https://stackoverflow.com/questions/6077675/why-am-i-seeing-typeerror-string-indices-must-be-integers">Why am I seeing &quot;TypeError: string indices must be integers&quot;?</a> but I'm not sure what kind of changes I should make to the code.</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-53-a47aee8a70a4&gt; in &lt;module&gt;()
        3 # Training dataset.
        4 dataset_train = RoadDataset()
  ----&gt; 5 dataset_train.load_road(&quot;/host/Mask_RCNN_karol_majek_Practice_2/road&quot;,&quot;train&quot;)
        6 dataset_train.prepare()
        7 
  
  &lt;ipython-input-48-5f64614b7c47&gt; in load_road(self, dataset_dir, subset)
       35         # The VIA tool saves images in the JSON even if they don't have any
       36         # annotations. Skip unannotated images.
  ---&gt; 37         annotations = [a for a in annotations if a['regions']]
       38 
       39         # Add images
  
  &lt;ipython-input-48-5f64614b7c47&gt; in &lt;listcomp&gt;(.0)
       35         # The VIA tool saves images in the JSON even if they don't have any
       36         # annotations. Skip unannotated images.
  ---&gt; 37         annotations = [a for a in annotations if a['regions']]
       38 
       39         # Add images
  
  TypeError: string indices must be integers
  </code></pre>
  <p>This is the chunk that the error is pointing to                       :</p>
  <pre><code>        # Train or validation dataset?
          assert subset in [&quot;train&quot;, &quot;val&quot;]
          dataset_dir = os.path.join(dataset_dir, subset)
  
       
          # We mostly care about the x and y coordinates of each region
          # Note: In VIA 2.0, regions was changed from a dict to a list.
          annotations = json.load(open(os.path.join(dataset_dir, &quot;via_project_train.json&quot;)))
          annotations = list(annotations.values())  # don't need the dict keys
  
          # The VIA tool saves images in the JSON even if they don't have any
          # annotations. Skip unannotated images.
          annotations = [a for a in annotations if a['regions']]
  
          # Add images
          for a in annotations:
              # Get the x, y coordinaets of points of the polygons that make up
              # the outline of each object instance. These are stores in the
              # shape_attributes (see json format above)
              # The if condition is needed to support VIA versions 1.x and 2.x.
              if type(a['regions']) is dict:
                  polygons = [r['shape_attributes'] for r in a['regions'].values()]
              else:
                  polygons = [r['shape_attributes'] for r in a['regions']] 
  
              # load_mask() needs the image size to convert polygons to masks.
              # Unfortunately, VIA doesn't include it in JSON, so we must read
              # the image. This is only managable since the dataset is tiny.
              image_path = os.path.join(dataset_dir, a['filename'])
              image = skimage.io.imread(image_path)
              height, width = image.shape[:2]
  
              self.add_image(
                  &quot;road&quot;,
                  image_id=a['filename'],  # use file name as a unique image id
                  path=image_path,
                  width=width, height=height,
                  polygons=polygons)
              
  </code></pre>
  <p>Json file:</p>
  <pre><code>{&quot;_via_settings&quot;:{&quot;ui&quot;:{&quot;annotation_editor_height&quot;:25,&quot;annotation_editor_fontsize&quot;:0.8,&quot;leftsidebar_width&quot;:18,&quot;image_grid&quot;:{&quot;img_height&quot;:80,&quot;rshape_fill&quot;:&quot;none&quot;,&quot;rshape_fill_opacity&quot;:0.3,&quot;rshape_stroke&quot;:&quot;yellow&quot;,&quot;rshape_stroke_width&quot;:2,&quot;show_region_shape&quot;:true,&quot;show_image_policy&quot;:&quot;all&quot;},&quot;image&quot;:{&quot;region_label&quot;:&quot;__via_region_id__&quot;,&quot;region_color&quot;:&quot;__via_default_region_color__&quot;,&quot;region_label_font&quot;:&quot;10px Sans&quot;,&quot;on_image_annotation_editor_placement&quot;:&quot;NEAR_REGION&quot;}},&quot;core&quot;:{&quot;buffer_size&quot;:&quot;18&quot;,&quot;filepath&quot;:{},&quot;default_filepath&quot;:&quot;G:\\My Drive\\Sivaraj\\FYP Part 2\\Classification Model\\mask_rcnn\\dataset\\train&quot;},&quot;project&quot;:{&quot;name&quot;:&quot;via_project_train&quot;}},&quot;_via_img_metadata&quot;:{&quot;roAd1.jpg11726&quot;:{&quot;filename&quot;:&quot;roAd1.jpg&quot;,&quot;size&quot;:11726,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[59,58,78,78],&quot;all_points_y&quot;:[29,47,46,28]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[75,75,62,62],&quot;all_points_y&quot;:[28,24,25,29]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[82,102,102,80],&quot;all_points_y&quot;:[25,24,44,45]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[110,110,159,158],&quot;all_points_y&quot;:[24,43,44,24]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd2.jpg11853&quot;:{&quot;filename&quot;:&quot;roAd2.jpg&quot;,&quot;size&quot;:11853,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[175,186,199,186],&quot;all_points_y&quot;:[67,56,68,78]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[187,198,187,175],&quot;all_points_y&quot;:[82,94,105,93]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[55,70,71,66,64,55,55,54],&quot;all_points_y&quot;:[30,35,55,56,54,55,58,56]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[96,100,104,101],&quot;all_points_y&quot;:[36,32,36,40]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[167,167,143,143,149,167],&quot;all_points_y&quot;:[42,28,29,40,45,44]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd3.jpg8500&quot;:{&quot;filename&quot;:&quot;roAd3.jpg&quot;,&quot;size&quot;:8500,&quot;regions&quot;:[],&quot;file_attributes&quot;:{}},&quot;roAd4.jpg10458&quot;:{&quot;filename&quot;:&quot;roAd4.jpg&quot;,&quot;size&quot;:10458,&quot;regions&quot;:[],&quot;file_attributes&quot;:{}},&quot;roAd5.jpg10578&quot;:{&quot;filename&quot;:&quot;roAd5.jpg&quot;,&quot;size&quot;:10578,&quot;regions&quot;:[],&quot;file_attributes&quot;:{}},&quot;roAd6.jpg19852&quot;:{&quot;filename&quot;:&quot;roAd6.jpg&quot;,&quot;size&quot;:19852,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[89,121,145,117],&quot;all_points_y&quot;:[132,107,135,157]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[289,289,294,294],&quot;all_points_y&quot;:[206,200,201,206]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[324,329,329,323,323],&quot;all_points_y&quot;:[202,202,195,195,201]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[357,366,365,356,358],&quot;all_points_y&quot;:[204,204,192,193,203]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd7.jpg11029&quot;:{&quot;filename&quot;:&quot;roAd7.jpg&quot;,&quot;size&quot;:11029,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[135,141,141,144,143,136,136],&quot;all_points_y&quot;:[88,88,90,90,85,85,88]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[130,130,123,124,127,127],&quot;all_points_y&quot;:[84,90,90,76,76,84]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[64,69,69,64],&quot;all_points_y&quot;:[64,64,79,78]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[71,81,81,72,72,71,71],&quot;all_points_y&quot;:[79,79,71,71,64,64,79]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[82,85,91,92,81,82],&quot;all_points_y&quot;:[66,66,68,80,79,66]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd8.jpg11339&quot;:{&quot;filename&quot;:&quot;roAd8.jpg&quot;,&quot;size&quot;:11339,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[69,124,123,67],&quot;all_points_y&quot;:[56,49,110,109]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd9.jpg8522&quot;:{&quot;filename&quot;:&quot;roAd9.jpg&quot;,&quot;size&quot;:8522,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[74,155,153,71],&quot;all_points_y&quot;:[8,5,129,128]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd10.jpg17990&quot;:{&quot;filename&quot;:&quot;roAd10.jpg&quot;,&quot;size&quot;:17990,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[135,136,48,42,41,47],&quot;all_points_y&quot;:[45,63,71,66,57,52]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd11.jpg29255&quot;:{&quot;filename&quot;:&quot;roAd11.jpg&quot;,&quot;size&quot;:29255,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[74,92,91,72],&quot;all_points_y&quot;:[86,86,101,102]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[106,188,188,106],&quot;all_points_y&quot;:[40,42,59,59]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[23,70,69,21],&quot;all_points_y&quot;:[50,43,59,65]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[229,229,286,285],&quot;all_points_y&quot;:[47,63,69,56]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[250,271,272,277,277,280,280,252],&quot;all_points_y&quot;:[16,22,25,25,23,25,39,32]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[294,298,299,296],&quot;all_points_y&quot;:[60,61,73,73]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[21,51,50,21],&quot;all_points_y&quot;:[24,16,31,40]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[0,14,14,1],&quot;all_points_y&quot;:[32,28,41,45]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[88,92,95,96,93,89,86,84,82,84],&quot;all_points_y&quot;:[64,65,67,72,76,78,78,76,71,67]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[76,81,87,90,90,84,79,75,72,74],&quot;all_points_y&quot;:[114,112,116,123,129,135,134,129,123,116]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[0,4,7,6,3,0],&quot;all_points_y&quot;:[111,112,118,122,127,123]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[212,216,223,226,226,222,218,213,209,208,208,208,212],&quot;all_points_y&quot;:[112,110,111,116,122,129,131,130,128,125,122,117,113]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[16,19,19,18,17,15,13,12,12,13],&quot;all_points_y&quot;:[47,48,52,55,56,57,57,56,53,49]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[136,138,138,140,140,141,141,136],&quot;all_points_y&quot;:[97,97,97,97,97,97,99,99]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd12.jpg7271&quot;:{&quot;filename&quot;:&quot;roAd12.jpg&quot;,&quot;size&quot;:7271,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[122,144,144,124],&quot;all_points_y&quot;:[106,105,115,118]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[146,163,164,146],&quot;all_points_y&quot;:[102,101,113,115]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd13.jpg102933&quot;:{&quot;filename&quot;:&quot;roAd13.jpg&quot;,&quot;size&quot;:102933,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[457,557,556,460],&quot;all_points_y&quot;:[115,119,164,168]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[557,748,747,559],&quot;all_points_y&quot;:[55,55,172,172]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[399,415,400,383],&quot;all_points_y&quot;:[256,275,288,275]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[421,431,421,413],&quot;all_points_y&quot;:[224,237,244,237]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[601,660,659,603],&quot;all_points_y&quot;:[244,248,268,264]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[363,385,384,362],&quot;all_points_y&quot;:[235,237,246,246]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[373,381,383,383,381,375,369,365,365,371],&quot;all_points_y&quot;:[225,225,219,214,209,206,210,214,221,226]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[372,382,383,371],&quot;all_points_y&quot;:[229,229,234,234]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[385,390,395,394,391,384,385,381,378,380],&quot;all_points_y&quot;:[229,228,225,221,213,213,219,225,225,227]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[677,683,680],&quot;all_points_y&quot;:[255,255,261]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[661,665,664,661],&quot;all_points_y&quot;:[261,261,267,267]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd14.jpg48044&quot;:{&quot;filename&quot;:&quot;roAd14.jpg&quot;,&quot;size&quot;:48044,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[0,90,103,1],&quot;all_points_y&quot;:[179,182,107,121]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd16.jpg251580&quot;:{&quot;filename&quot;:&quot;roAd16.jpg&quot;,&quot;size&quot;:251580,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[325,325,486,493],&quot;all_points_y&quot;:[592,720,720,599]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[515,805,807,515],&quot;all_points_y&quot;:[598,603,722,722]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[408,453,448,410],&quot;all_points_y&quot;:[798,800,811,809]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[410,424,450,450,413],&quot;all_points_y&quot;:[830,836,838,814,809]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd17.jpg54627&quot;:{&quot;filename&quot;:&quot;roAd17.jpg&quot;,&quot;size&quot;:54627,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[29,196,194,30],&quot;all_points_y&quot;:[90,85,144,146]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[268,269,468,469],&quot;all_points_y&quot;:[81,139,137,75]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[226,243,255,255,254,250,245,238,228,220,214,209,217],&quot;all_points_y&quot;:[122,126,137,145,156,160,166,169,170,166,160,149,133]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[192,248,247,190],&quot;all_points_y&quot;:[181,183,233,232]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd27.jpg14717&quot;:{&quot;filename&quot;:&quot;roAd27.jpg&quot;,&quot;size&quot;:14717,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[166,245,248,169],&quot;all_points_y&quot;:[41,39,55,57]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[165,247,248,167],&quot;all_points_y&quot;:[57,58,68,70]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[166,245,247,168],&quot;all_points_y&quot;:[74,72,86,89]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[254,293,293,265,260,254],&quot;all_points_y&quot;:[76,77,89,89,86,85]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}},{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[166,251,250,171],&quot;all_points_y&quot;:[91,92,109,112]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}},&quot;roAd28.jpg10231&quot;:{&quot;filename&quot;:&quot;roAd28.jpg&quot;,&quot;size&quot;:10231,&quot;regions&quot;:[{&quot;shape_attributes&quot;:{&quot;name&quot;:&quot;polygon&quot;,&quot;all_points_x&quot;:[0,147,145,3],&quot;all_points_y&quot;:[28,60,96,83]},&quot;region_attributes&quot;:{&quot;type&quot;:&quot;sign&quot;,&quot;name&quot;:&quot;sign&quot;}}],&quot;file_attributes&quot;:{}}},&quot;_via_attributes&quot;:{&quot;region&quot;:{&quot;name&quot;:{&quot;type&quot;:&quot;text&quot;,&quot;description&quot;:&quot;name of the object&quot;,&quot;default_value&quot;:&quot;not_defined&quot;},&quot;type&quot;:{&quot;type&quot;:&quot;dropdown&quot;,&quot;description&quot;:&quot;category of the object&quot;,&quot;options&quot;:{&quot;sign&quot;:&quot;Sign&quot;},&quot;default_options&quot;:{&quot;sign&quot;:true}}},&quot;file&quot;:{}},&quot;_via_data_format_version&quot;:&quot;2.0.10&quot;,&quot;_via_image_id_list&quot;:[&quot;roAd1.jpg11726&quot;,&quot;roAd2.jpg11853&quot;,&quot;roAd3.jpg8500&quot;,&quot;roAd4.jpg10458&quot;,&quot;roAd5.jpg10578&quot;,&quot;roAd6.jpg19852&quot;,&quot;roAd7.jpg11029&quot;,&quot;roAd8.jpg11339&quot;,&quot;roAd9.jpg8522&quot;,&quot;roAd10.jpg17990&quot;,&quot;roAd11.jpg29255&quot;,&quot;roAd12.jpg7271&quot;,&quot;roAd13.jpg102933&quot;,&quot;roAd14.jpg48044&quot;,&quot;roAd16.jpg251580&quot;,&quot;roAd17.jpg54627&quot;,&quot;roAd27.jpg14717&quot;,&quot;roAd28.jpg10231&quot;]}
  </code></pre>
  <p>Upon implementing the edited version of the answer, this is the new error received:</p>
  <pre><code>  File &quot;road.py&quot;, line 370, in &lt;module&gt;
      train(model)
    File &quot;road.py&quot;, line 189, in train
      dataset_train.load_road(args.dataset, &quot;train&quot;)
    File &quot;road.py&quot;, line 120, in load_road
      annotations = annotations[&quot;_via_img_metadata&quot;]
  TypeError: list indices must be integers or slices, not str
  </code></pre>