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

[feat]: Adding Offline Support for Interactive Web Demo #215

Merged
merged 3 commits into from
Aug 22, 2023

Conversation

Neilblaze
Copy link
Contributor

Description 🤔

This update aims to provide 100% offline support for the Interactive Web Demo (ATM Playground) that demonstrates touchless interactions using the MediaPipe Machine Learning Library.

Advantages 🚀

If precaching is enabled, the app will work offline after the first load. 🎉

Caching assets with a service worker can speed up repeat visits and provide offline support. Workbox makes this easy and is included in React App by default. Feel free to explore this guide to know more!

📌 For security purposes (especially to avoid cache-poisoning), the support has been limited to active session only, and cache expiration of 30 days has been set with stale-while-revalidate strategy for achieving best performance.

Additionally, a few other optimizations include updates to Kernel, minor UI bug fixing & adding LICENSE header to index.html.

🔸 Parent Repo → @Neilblaze/GSOC-23
🔸 Live Demo → Here


cc: @jenperson

Testing

To test the changes, open the live demo on your browser. If you're accessing it for the first time, it might take some time to load the model & assets on your local (depending on your internet speed). Once it's loaded, feel free to explore and interact with the demo. Disconnect the internet and then perform a refresh (or press F5); it should still load and work even in offline mode!

To extend it further, open DevTools by pressing Control+Shift+J or Command+Option+J (Mac). The Console panel opens. Then click on the Network tab, which will open the Network panel. Click on No Throttling & uncheck the Disable Cache to make sure the cached data is accessible & then perform a normal refresh to make it run while offline. If you want to compare different trials, you can use the profiler to capture the waterfall. The mean result of these trials can be found above.

Please note that if you terminate the current browser session, you will need to perform the initial load using an internet connection.


  • Performance Boost6.1s from 16.8s, i.e. 275% (after 1st load) 📈
  • Browser : Google Chrome — Version 116.0.5845.97 (Official Build) (64-bit)

Checklist

Please ensure the following items are complete before submitting a pull request:

  • My code follows the code style of the project.
  • I have updated the documentation (if applicable).

Type of Change

Please check the relevant option below:

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update (non-breaking change which updates documentation)
  • New feature (non-breaking change which adds functionality)

Neilblaze and others added 3 commits August 22, 2023 23:18
Extras:

- 100% offline support (same session)
- add & register service-worker
- added workbox dependencies
- link `hand_landmarker.task` locally
- added LICENSE header to index.html
- updated checks in Kernel
- fixed minor UI bug in Landing
@jenperson
Copy link
Contributor

Thanks for this! Super impressive as always 😄

@jenperson jenperson merged commit c9eeff6 into google-ai-edge:main Aug 22, 2023
1 check passed
palrahul pushed a commit to palrahul/mediapipe that referenced this pull request Sep 27, 2023
[feat]: Adding Offline Support for Interactive Web Demo
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

Successfully merging this pull request may close these issues.

2 participants