Skip to content
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

Move away from POST and use sockets ? #1

Open
wardhanster opened this issue Dec 26, 2017 · 2 comments
Open

Move away from POST and use sockets ? #1

wardhanster opened this issue Dec 26, 2017 · 2 comments

Comments

@wardhanster
Copy link

I was wondering if this was possible and if this is a possible route to go
in order to eliminate the poor frame rate coming in because of the polling method employed ?
Also is I was wondering if there was any specific reason you used POST method over sockets ?

Any Insights would be amazing.
Thanks for creating this !

@chadwallacehart
Copy link
Member

I agree websockets is mostly better for this application, but I do not think that will have a major impact on the response time.

I did not do websockets originally because the framerate bottleneck in my case is actually running the inference on the image. On my MacBook Pro this takes 700 to 1300 ms per image with a 1280 px uploadWidth. The several ms saved by moving to websockets was not worth the added troubleshooting overhead - it is very easy to inspect the POST message & response with the built in debugging tools in all browsers.

The easiest way to increase the responsiveness is to drop the uploadWidth parameter to 320. This will decrease the image recognition accuracy, but that may be ok depending on your application. I quick test I just did dropped the total upload, inference, and response time to 120-130 ms. For added cost, you can also get a GPU or something like Intel's Movidius to speed processing.

I am working on applying this codebase to a home robotics project that uses websockets. It is likely I will provide an update that uses websockets in the coming weeks.

@chadwallacehart
Copy link
Member

I'm not sure when/if I will add WebSockets for this project, but you can see an example WebSocket implementation I did on another repo here: https://github.com/chadwallacehart/sense_hat_server

In that project, I used flask_socketio. This line here shows how you could respond to an incoming image from the web client: https://github.com/chadwallacehart/sense_hat_server/blob/3c6e4dfc849772643112d6f21c688b80c9c2cce1/server.py#L167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants