Hi guys i have a problem with my c# - python code!
I have a code for image recognizing. It works fine in my vs code. Heres a screenshot
And this code works fine in visual studio in python solution. But when I try to run it inside my c# code it does not work. My model is loading properl;y and path to my file is fine too. Libraries connects also in proper way. I run this code using pythonnet inside c#. But my code stops on that line "prediction = model.predict(processed_image)" with that error. Mb someone knows how to fix it or have a solution?
9 Replies
What's the call stack on that exception?
Also please post code as text, not images. See $code. I want to ctrl-f through it to see if there's a
write
function anywhere, but I can't, because it's an image.To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/ Its c# code that needs to get just a string from my python code. I'm using pythonnet here for that.
There's python code it works well. libraries also imports well(i checked the possibility to return every library version as string from that method so libraries is not a problem. Also filepath is fine and kernel trained model is fine too. This code works in another solution or in vs code jupiter notebook or even from my desctop in cmd/ But when i start it from c# it stops on that line and then i heave this kind of exception Python.Runtime.PythonException: ''NoneType' object has no attribute 'write''
also there is my call stack
and there is exception screenshot
@canton7
and there s a trained model and a picture wich i used for recognizing
Desired output is Predicted class: 35
Its not necessary because the same code works in just python solution but dont work when i start it in c#. I already had an advice about ctrl+f for .where so it's not the reason for exception