Изменить размер партии предварительно обученной модели - PullRequest
0 голосов
/ 21 января 2020

Я пытаюсь загрузить модель из здесь , чтобы сделать выводы для изображений. Суть в том, что я хочу прогнозировать более одного изображения за раз, но при попытке сделать это я получаю следующую ошибку:

Код:

tensor = tf.convert_to_tensor(np.array([np.asarray(resized_image)]))
tensor2 = tf.convert_to_tensor(np.array([np.asarray(resized_image), np.asarray(resized_image)]))

test = model_new.signatures['serving_default'](tensor)
test2 = model_new.signatures['serving_default'](tensor2) 

Ошибка:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<timed exec> in <module>

~/miniconda3/envs/tex/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in __call__(self, *args, **kwargs)
   1079       TypeError: For invalid positional/keyword argument combinations.
   1080     """
-> 1081     return self._call_impl(args, kwargs)
   1082 
   1083   def _call_impl(self, args, kwargs, cancellation_manager=None):

~/miniconda3/envs/tex/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in _call_impl(self, args, kwargs, cancellation_manager)
   1119       raise TypeError("Keyword arguments {} unknown. Expected {}.".format(
   1120           list(kwargs.keys()), list(self._arg_keywords)))
-> 1121     return self._call_flat(args, self.captured_inputs, cancellation_manager)
   1122 
   1123   def _filtered_call(self, args, kwargs):

~/miniconda3/envs/tex/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py in _call_flat(self, args, captured_inputs, cancellation_manager)
   1208                      arg_name, arg,
   1209                      self._func_graph.inputs[i].shape,
-> 1210                      arg.shape))
   1211       elif (self._signature is not None and
   1212             isinstance(self._signature[i], tensor_spec.TensorSpec)):

ValueError: The argument 'ImageTensor' (value Tensor("Const_3:0", shape=(2, 342, 513, 3), dtype=uint8)) is not compatible with the shape this function was traced with. Expected shape (1, None, None, 3), but got shape (2, 342, 513, 3).

If you called get_concrete_function, you may need to pass a tf.TensorSpec(..., shape=...) with a less specific shape, having None on axes which can vary.

Что указывает на то, что модель имеет фиксированный размер партии 1. Есть идеи, как ее изменить?

...