Код: Выделить всё
for trig in json_dict[vidname]["triggers"]:
line = json_dict[vidname]["triggers"][trig]["line"]
point = json_dict[vidname]["triggers"][trig]["point"]
lines.append(bbox_trigger.VectorTrigger(vidname, line, point, constants.LT_MAX_DISTANCE, constants.LT_FRAME_OFFSET))
Я получаю следующую ошибку TypeError: строковые индексы должны быть целыми числами, а не 'str' в первой строке кода выше (
Код: Выделить всё
for
Полная ошибка трассировки, которую я получаю:
Код: Выделить всё
C:\Users\phoen\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\models\_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
warnings.warn(
C:\Users\phoen\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\models\_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet50_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet50_Weights.DEFAULT` to get the most up-to-date weights.
warnings.warn(msg)
C:\Users\phoen\Downloads\HumanBehaviorRE-ID-master\attribute_extractors.py:38: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
self.model.load_state_dict(torch.load(weights_path, map_location=torch.device('cpu')))
C:\Users\phoen\AppData\Local\Programs\Python\Python311\Lib\site-packages\torchvision\models\_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=FasterRCNN_ResNet50_FPN_Weights.COCO_V1`. You can also use `weights=FasterRCNN_ResNet50_FPN_Weights.DEFAULT` to get the most up-to-date weights.
warnings.warn(msg)
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\phoen\Downloads\HumanBehaviorRE-ID-master\vector_trigger_pipeline.py", line 401, in
sys.exit(main())
^^^^^^
File "C:\Users\phoen\Downloads\HumanBehaviorRE-ID-master\vector_trigger_pipeline.py", line 351, in main
trigger_causes = config_parser.extract_line_trigger_list(json_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\phoen\Downloads\HumanBehaviorRE-ID-master\config_parser.py", line 28, in extract_line_trigger_list
for trig in json_dict[vidname]["triggers"]:
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'
Код: Выделить всё
json_dict_vid = eval(json_dict[vidname])
for trig in json_dict_dic["triggers"]:
line = json_dict[vidname]["triggers"][trig]["line"]
point = json_dict[vidname]["triggers"][trig]["point"]
lines.append(bbox_trigger.VectorTrigger(vidname, line, point, constants.LT_MAX_DISTANCE, constants.LT_FRAME_OFFSET))
Код: Выделить всё
TypeError: eval() arg 1 must be a string, bytes or code object
Я не понимаю, как json_dict[vidname] может быть строкой, а не строкой.< /p>
Кроме того, если я добавлю raise ValueError(type(json_dict[vidname])) перед циклом for, я получу следующую ошибку: ValueError: . Итак, json_dict[vidname] — это словарь?
Будем очень благодарны за любую помощь!
Подробнее здесь: https://stackoverflow.com/questions/791 ... t-a-string