Open davidcpham97 opened 4 years ago
You can only parse the numpy array of a single image at a time.
Hi @OlafenwaMoses I see here https://github.com/OlafenwaMoses/ImageAI/issues/49#issuecomment-408797828 that you say it's possible to pass numpy arrays to the prediction function. In reference to @davidcpham97 issue, should he just pass a single numpy array at a time which represents an image (no need for jpg file conversion). Is the frame concatination the issue or is it the formatting of the narray that is the issue?
Thank you for your help.
@lukeseed Thanks for the comment. The function expects the array to be that of a single image frame. Therefore, any attempt to concatenate multiple image arrays of expand the dimension will lead to an error.
@OlafenwaMoses I'm trying to send a mel spectrogram numpy array (generated via melspec = librosa.feature.melspectrogram(y=stack, sr=rate, n_fft=n_fft, hop_length=hop_length, n_mels=n_mels)) to the prediction function of imageai and am receiving the following error that the shape is wrong. As far as I know, the shape of a jpg {used to train the model} should be (h,w,c) which is 3 dimensions, correct? Why would the model be expecting an array of 4 dimensions?
Thanks for your advice.
Inputs to the model are y default in batches. However, for API simplicity and memory optimization for low end compute, the single image parsed in is reshaped into a 4 dimensional input before it is fed into the prediction model.
I am passing a numpy array to the prediction model using: combine = np.concatenate(frames) (combines an array of numpy arrays) to predictions, probabilities = prediction.predictImage(combine, result_count=2, input_type="array")
I am getting this error when doing so: ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (1, 224, 224)
When I tried to add an extra dimension using: combine = np.expand_dims(combine, axis=0) I get this error: ValueError: You have parsed in a wrong numpy array for the image
Is it possible to concatenate multiple nimpy arrays together and pass it to the prediction model?