Dark-Chocolate icon indicating copy to clipboard operation
Dark-Chocolate copied to clipboard

TypeError with curr['id']

Open aidamanzano opened this issue 4 years ago • 0 comments

Hi thank you for your code, this is exactly what I am looking for! I have a COCO formatted file of .json annotations for this dataset and I am trying to generate a .txt file for each image with the same name of the image and the YOLOv3 format. When I run the code with the path to my annotations file I get this error: Traceback (most recent call last): File "dark_chocolate.py", line 55, in <module> dark_chocolate(opt.input_path) File "dark_chocolate.py", line 47, in dark_chocolate lambda x: ingredients(x, _path)) File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 538, in map_ return list(itermap(collection, iteratee)) File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 1103, in itermap for result in iteriteratee(collection, iteratee): File "/home/aida/.local/lib/python3.7/site-packages/pydash/helpers.py", line 97, in iteriteratee yield (callit(cbk, item, key, obj, argcount=argcount), File "/home/aida/.local/lib/python3.7/site-packages/pydash/helpers.py", line 38, in callit return iteratee(*args[:argstop]) File "dark_chocolate.py", line 47, in <lambda> lambda x: ingredients(x, _path)) File "dark_chocolate.py", line 28, in ingredients xoxo = _.reduce_right(json.load(f), coco_mixer) File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 829, in reduce_right return reduce_(collection, iteratee, accumulator) File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 795, in reduce_ result = callit(iteratee, result, item, index, argcount=argcount) File "/home/aida/.local/lib/python3.7/site-packages/pydash/helpers.py", line 38, in callit return iteratee(*args[:argstop]) File "dark_chocolate.py", line 7, in coco_mixer return _.flat_map(acc, lambda xo: { File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 264, in flat_map return pyd.flatten(itermap(collection, iteratee=iteratee)) File "/home/aida/.local/lib/python3.7/site-packages/pydash/arrays.py", line 527, in flatten return flatten_depth(array, depth=1) File "/home/aida/.local/lib/python3.7/site-packages/pydash/arrays.py", line 572, in flatten_depth return list(iterflatten(array, depth=depth)) File "/home/aida/.local/lib/python3.7/site-packages/pydash/arrays.py", line 2243, in iterflatten for item in array: File "/home/aida/.local/lib/python3.7/site-packages/pydash/collections.py", line 1103, in itermap for result in iteriteratee(collection, iteratee): File "/home/aida/.local/lib/python3.7/site-packages/pydash/helpers.py", line 97, in iteriteratee yield (callit(cbk, item, key, obj, argcount=argcount), File "/home/aida/.local/lib/python3.7/site-packages/pydash/helpers.py", line 38, in callit return iteratee(*args[:argstop]) File "dark_chocolate.py", line 8, in <lambda> "id": curr['id'], TypeError: list indices must be integers or slices, not str I'm a complete beginner so apologies if this is a very trivial mistake, but I'm not sure what I am doing wrong?

aidamanzano avatar May 14 '20 17:05 aidamanzano