How to generate the mean file for classifier which is used by deepstream?

I’m trying to load a custom classifier inside deepstream and the issue that I’m facing right now is as follows,

When I used the deepstream test 2 app to perform inference on the people object and the car color classifier, if I don’t supply the mean file the classifier results remain the same, i.e it classifies all the people as to be of one single color, but when I give the mean file I see the change in classifier’s output.

My main task in hand was to feed in a custom classifier neural network, however I’m failing at the part as to how to generate the mean file to feed in the config file. I have trained my model using caffe and I have the mean file. Deepstream successfully converts the model to engine file and saves it but it fails at parsing the mean file.

On closer inspection I found the content of the mean file generated by the Caffe command,

compute_image_mean -backend=lmdb ./train_lmdb mean.binaryproto

is a binary file and the mean file used in deepstream is different, I was able to open the mean file in an editor (deepstream mean file) and read it’s content but not the one generated from caffe.

So how do we generate this mean file?

It’s not deepstream issue. Please deploy your model by tensorRT firstly
Deepstream pre-preprocess doc is here:

Hey @ChrisDing, I was able to get the classifier working, the issue seemed to be the model color format and the mean-file which is listed in the link below,

Could you let me know as to how those mean.ppm files are generated in deepstream?


>>> import PIL
>>> from PIL import Image
>>> import numpy as np

>>> z=np.array([124, 117, 104])               
>>> z=np.expand_dims(np.expand_dims(np.array([124, 117, 104]), axis=0), axis=0)
>>> z=np.broadcast_to(z, (224, 224, 3))
>>> z.shape
(224, 224, 3)

>>> Image.fromarray(np.array(z, dtype=np.uint8))
<PIL.Image.Image image mode=RGB size=224x224 at 0x7F4EABA02A90>
>>> Image.fromarray(np.array(z, dtype=np.uint8)).save('/home/cding/x.ppm')

Hi @ChrisDing,

I have the mean.binaryproto for my caffe model already. How can I create a mean.ppm file to load the model as a secondary model along with the tltl pretrained facedetectIR model as primary?

Hi rohitnairkp,

Please help to open a new topic for your issue. Thanks

The python code is right above.

@beefshepherd Did it work for you?