Home > Back-end >  Onnx inference throws an error with numpy float32 datatype inside the streamlit framework
Onnx inference throws an error with numpy float32 datatype inside the streamlit framework

Time:04-03

In one of datascience web app project, I designed an app to predict the type of plant disease. It contains onnx models. The prediction runs without an error standalone. But inside the streamlit code, it raises an error:

UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('<U23'), dtype('float32')) -> None**

Did someone come across this kind of a situation?

enter image description here

This is the link to the project files: enter image description here

Code

if conf is True: #predict button is pressed, you need a way of identifying is it pressed or not
    # prediction - pred_out(img, model_selector, plant_model_dictionary)[0]
    prediction = pred_out(img, model_selector, plant_model_dictionary)[0]
    st.write(f'prediction: {prediction}')
    # max_ind = np.where(prediction==max)[0][0]
    # print(max_ind)
    st.write(f'prediction max index: {prediction.argmax(axis=0)}')
  • Related