zkmkarlsruhe / ofxTensorFlow2

TensorFlow 2 AI/ML library wrapper for openFrameworks
Other
113 stars 17 forks source link

training a model #8

Closed natxopedreira closed 3 years ago

natxopedreira commented 3 years ago

I trained a new model for neural style using the python files in your repo, that create a model is pb format instead of checkpoints as original repo.

But when i try to load the model in the of code i get a black screen and a msg on console [warning] ofxTensorFlow2: shape mismatch at dimension 0 for lhs [480, 640, 3] and rhs [640, 480, 3]

I opened the model with Netron and i see a input called "serving_default_input_1" with size float32[?,640,480,3] so i don't understand whats happening

Can you give me some clue?

danomatika commented 3 years ago

I am personally no AI expert, but it looks like you have the sizes swapped:

lhs [480, 640, 3] -> rhs [640, 480, 3]

I would think the lhs should be [640, 480, 3].

natxopedreira commented 3 years ago

Thanks, yep you are right. I explained myself wrong

In teory you modify the training python script to produce the model in pb format and with the correct sizes, or thats what i understand per the readme. I trained a new model using that script.

Is not really a problem as im trying again with the original repo script, but i think the result i get was not what is expected

Or mabye i did something wrong... that is very possible :)

danomatika commented 3 years ago

Ping @bytosaur

bytosaur commented 3 years ago

Hey there!

I am currently on a leave but I can look deeper into it on Monday.

From the first look I think I may have mixed up the dimensions there. There is a checkpoint2savedmodel.py script that converts the original Checkpoints to savedModels and saves them as 480x640. This should be the expected input shape for the example.

Thanks for checking it out! I ll change that ASAP

natxopedreira commented 3 years ago

Is not really a problem and easy for someone to fix https://github.com/zkmkarlsruhe/ofxTensorFlow2/blob/b9c3845ba5843bd12dd4f7f4649ba401109455a9/example_style_transfer/python/train.py#L146

Addon is great, and really easy to setup on linux, thank you.