-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when implement ObjectDetection as API in flask #159
Comments
This error seem to be solved after i add K.clear_session() before |
The error is occurring because for each inference, you load the detection model. Although , the K.clear_session() function does reset the detection instance and prevents the error, there will still be latency for each time the model loads. What you can do is create the detection instance as a global value and load the model outside the function. |
Thanks for your respond.
|
I am also trying to use imageai for object detection and facing same issue when creating detection instance as global variable. If I use |
I seem that it is not working on multiple thread. |
I am having the same issue between Flask and imageAI when creating the
when calling Interestingly, the model I'm loading is Upon closer inspection, it appears to raise this exception when As far as my understanding goes, when run in debug mode (which is how i'm running flask) it is run on a single thread by default. So I don't know if multi-threading is the issue, although there does seem to be a weird interaction between flask and ImageAI |
I have the same problem, has someone solved it or found a workaround? |
I had the same problem a week ago.
the most important points is set the app.run(threaded=False). |
I have another solution to solve this problem.
the most important points is set the thread_safe=True. If you do that, you will find we can load model just one time and can use in many threads. |
@xiluzi Both solution worked. |
Hi, do you know a solution for the prediction procedure? I'm trying to do the same as you do but with the prediction function and its throwing me the same error. |
@dntzbgh Both of the above mentioned solutions by xiluzi solves it. |
@akashtyagi08 yes, it solves it for the detection function. I was asking if anyone tried to do the same for a prediction since I'm trying to use both in a flask app. |
Yes, when using prediction and Detection collectively in the same api, the issue still persist. I tried few workaround but were unsuccessful. |
@xiluzi can you please help me in understanding the issue why its throwing error when I try to call detectObjectsFromImage method from flask api method without loading model again. If I load the model in api post method and call for detectObjectsFromImage method, its giving results with a delay of loading model time.. but I m trying to reduce this delay of loading model time in each API call. Please refer #531 to see my code. please help in understand why its not working in my code but working fine in your above code. thanks in advance.. |
I am having an issue when trying to implement ObjectDetection as an api with Flask framework
My source code is just the simple use of ObjectDetection
Problem is the api only success on the first request. From second request, it comes with following error:
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(3, 3, 3, 16), dtype=float32) is not an element of this graph.
Full stack trace:
The text was updated successfully, but these errors were encountered: