80979
モデルを画像に適用するyolo_video.pyが実行できず、次のエラーが出る

```

    Using TensorFlow backend.
    Image detection mode
     Ignoring remaining command line arguments: ./path2your_video,
    2021-08-21 00:25:52.626058: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    Traceback (most recent call last):
      File "C:\Users\your\OneDrive\デスクトップ\keras-yolo3-master\yolo.py", line 70, in generate
        self.yolo_model = load_model(model_path, compile=False)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\models.py", line 243, in load_model
        model = model_from_config(model_config, custom_objects=custom_objects)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\models.py", line 317, in model_from_config
        return layer_module.deserialize(config, custom_objects=custom_objects)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\layers\__init__.py", line 55, in deserialize
        printable_module_name='layer')
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\utils\generic_utils.py", line 144, in deserialize_keras_object
        list(custom_objects.items())))
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 2514, in from_config
        process_layer(layer_data)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 2500, in process_layer
        custom_objects=custom_objects)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\layers\__init__.py", line 55, in deserialize
        printable_module_name='layer')
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\utils\generic_utils.py", line 146, in deserialize_keras_object
        return cls.from_config(config['config'])
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 1271, in from_config
        return cls(**config)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
        return func(*args, **kwargs)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\layers\convolutional.py", line 1783, in __init__
        super(UpSampling2D, self).__init__(**kwargs)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 293, in __init__
        raise TypeError('Keyword argument not understood:', kwarg)
    TypeError: ('Keyword argument not understood:', 'interpolation')
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 686, in _call_cpp_shape_fn_impl
        input_tensors_as_shapes, status)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in __exit__
        c_api.TF_GetCode(self.status.status))
    tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 0 in both shapes must be equal, but are 1 and 21. Shapes are [1,1,1024,255] and [21,1024,1,1]. for 'Assign_360' (op: 'Assign') with input shapes: [1,1,1024,255], [21,1024,1,1].
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "yolo_video.py", line 73, in <module>
        detect_img(YOLO(**vars(FLAGS)))
      File "C:\Users\your\OneDrive\デスクトップ\keras-yolo3-master\yolo.py", line 45, in __init__
        self.boxes, self.scores, self.classes = self.generate()
      File "C:\Users\your\OneDrive\デスクトップ\keras-yolo3-master\yolo.py", line 74, in generate
        self.yolo_model.load_weights(self.model_path) # make sure model, anchors and classes match
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 2656, in load_weights
        f, self.layers, reshape=reshape)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\engine\topology.py", line 3382, in load_weights_from_hdf5_group
        K.batch_set_value(weight_value_tuples)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\keras\backend\tensorflow_backend.py", line 2368, in batch_set_value
        assign_op = x.assign(assign_placeholder)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\ops\variables.py", line 599, in assign
        return state_ops.assign(self._variable, value, use_locking=use_locking)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\ops\state_ops.py", line 280, in assign
        validate_shape=validate_shape)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 61, in assign
        use_locking=use_locking, name=name)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
        op_def=op_def)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\ops.py", line 3273, in create_op
        compute_device=compute_device)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\ops.py", line 3313, in _create_op_helper
        set_shapes_for_outputs(op)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\ops.py", line 2501, in set_shapes_for_outputs
        return _set_shapes_for_outputs(op)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\ops.py", line 2474, in _set_shapes_for_outputs
        shapes = shape_func(op)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\ops.py", line 2404, in call_with_requiring
        return call_cpp_shape_fn(op, require_shape_fn=True)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 627, in call_cpp_shape_fn
        require_shape_fn)
      File "C:\Users\your\anaconda3\envs\yolo_you5\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 691, in _call_cpp_shape_fn_impl
        raise ValueError(err.message)
    ValueError: Dimension 0 in both shapes must be equal, but are 1 and 21. Shapes are [1,1,1024,255] and [21,1024,1,1]. for 'Assign_360' (op: 'Assign') with input shapes: [1,1,1024,255], [21,1024,1,1].
    
```

使っているのはkeras-yolo(<https://github.com/qqwweee/keras-
yolo3>)でtrain.pyのバッチサイズや画像のサイズを変え、model.save_weights()をmodel.save()に変えた以外ほとんど変えていません。  
また、環境はwindows10でanacondaにpython3.5.6 keras2.1.5 tensorflow1.6.0を入れています  
エラーについて調べてみた結果、一つ目のエラーは[ここ](https://github.com/keras-team/keras/issues/12354)  
よりkerasのバージョンを変えるか（yolo3公式のkerasのバージョンを使っているので変えたくありません）、「upSampling2D関数の有効な引数リストから「interpolation」が除外されている」のをどうにかすることで解決できるそうですが実際にどのコードまたは変数をどのように編集すればよいのかわかりません。

どうするか知っている方は教えてください。さらに情報が必要なら喜んで教えます。
CC BY-SA 4.0
2021-08-20T15:52:07.260
80939
2021-08-23T04:00:15.247
2021-08-23T04:00:15.247
47739
47739
question
python tensorflow keras
TypeError: ('Keyword argument not understood:', 'interpolation')とDimension 0 in both shapes must be equalというエラーが二つkeras-yoloのyolo_video.pyを実行すると出てしまう
自己解決しました。  
yolo.pyの16行目の  
"classes_path": 'model_data/coco_classes.txt',  
で読み込んでいるtxtファイルを自分が認識させたいものの名前（クラス）を並べたものにしなければいけないのですが変え忘れていました。  
すごく初歩的なミスで情けない限りです。
CC BY-SA 4.0
2021-08-23T03:45:47.770
80979
2021-08-23T03:45:47.770
47739
80939
answer