Closed aureosun closed 7 years ago
Hi, I didn't understand your question clearly. could you clarify the following questions I have? 1) do you want to classify 100 images per second or do you want to process a video stream which you are getting at the rate of 100 fps?
apart from that, If I'm not wrong, mobilenet does not use Inception right? If that is the case, then the label_image.py will require a lot of changes as it was written with inception in mind.
I am not sure how much of help I can be as I haven't worked on Mobilenet. Can you upload the model files you have to google drive and share the link here? I'll have a look.
I want to use mobilenet to classify about 100 images per second,the method to train mobilenet has updated by tensorflow team in the code in the official repo of tensorflow,that is tensorflow/tensorflow/examples/image_retraining/retrain.py and with this I got my own retrained model,and the code can also be used to train inception_v3,to classify images, I still use the code tensorflow/tensorflow/examples/label_image/label_image.py ,and it can only input one image and got the prediction,so I want to modify the label_image.py in tensorflow/tensorflow/examples/label_image/label_image.py so as to make it classify a batch of images at the same time ?So sir,could you please help me?and here is a blog (https://hackernoon.com/building-an-insanely-fast-image-classifier-on-android-with-mobilenets-in-tensorflow-dc3e0c4410d4?gi=3a38218370d2)about how to train and test,I just follow it and I don't know how to classify images in batches?Need your help!@akshaypai
So, if you are able to test once, the majority of your work is done. What you would have to do is, create a script which opens a tensorflow session once and loads the trained model in it and keeps the session alive.
Once that is done, expose an API using a simple python framework like Flask and keep accepting images and classifying them one after another.
I'm sorry to break it to you, but classifying 100 images per second is extremely difficult. You would need a lot of devices running in parallel to handle that. On a system with mediocre GPU, it will take around 15 milliseconds to classify an image which isn't too big. which means in a second you can classify less than 10 images. With some parallelism probably you can do 15 or 20 and not more than that per device.
However, you can create an API which accepts images and gives you the classification response. I have the code for doing it, I'll try uploading it tomorrow. But even with that, you might have to do some changes to make your model run.
And Sir,I have modify the code label_image.py to make it accepting images and classifying them one after another.But the speed will be slower and slower,at first,as you mentioned above,it takes about 20ms but when I read the 500th image,it takes about 2s,and I find the problem lies in the function read_tensor_from_image_file,I tried to make it process a batch of images but failed.So do you have any suggestions?and can you give me the link of your script?
If you make it a stateless process, like using REST, it will not decrease in performance. EIther your memory is getting full or a cleanup is required after each classification. Closing this thread for now.
Sir,I have trained a model on my own data which is for flower classification,and it has three classes, that is azalea,tulip and lily,and now I want to use the model to classify them,so How to use the model to classify the data,the speed I need is about 100fps,and the model I use is mobilenet,and I have tried to modify the code in tensorflow :tensorflow/tensorflow/examples/label_image/label_image.py,but I failed,could you please help me?