Code Monkey home page Code Monkey logo

web-ai-showcase's Introduction

Web-AI-showcase

This project is a website which demonstrates some emerging Web AI demos that can run on Intel AI PCs. The AI tasks are executed on client side through WebAssembly and WebGPU technology.

Requirements

  • node 16+
  • npm

Environment Setup

Install necessary dependencies

npm install

Model downloading

This website itself is a static page without dependency to any server APIs. However the models needed by every AI tasks must be downloaded from somewhere to the users' browser.

To better adapt to various deployment environments, we provide two modes for model downloading:

  1. Remote mode (Download models from huggingface)

    In this mode, the end users'(who use the browser to access this web page) browsers will fetch model files from huggingface.

    This mode is useful when the end users can access huggingface easily or the hosting server can't store large files.

  2. Hosting mode (Download models from hosting server)

    In this mode, we can download the required models to the hosting server in advance, and the end users' browsers will fetch model files from the server hosting this web page.

    This mode is useful when the end users don't have access to huggingface or their network is too slow to download large files from huggingface.

    In Hosting mode only models are deployed on the hosting server, the end users' browser still need to fetch some other resources (e.g. some wasm files) through CDN, this means Hosting mode is not suitable for pure offline environment.

Note: LLM-Gemma uses the gemma-2b-it-gpu-int4 model, which must be downloaded and loaded manually before inference. See this for more details.

Build the showcase

The build phase will bundle the source code.

If using Hosting mode, it will also download required models and put into correct directories.

Build with Remote mode

  npm run prod:use-remote-models

Build with Hosting mode

  npm run prod

This may take a long time to download model files (~3GB to download).

Launch the showcase

Setup https server

SSL Preparation

HTTPS is required since we use WebGPU in some samples and WebGPU is only available in secure-context.

We provide a npm script to generate ssl based on openssl. Try to install openssl if you don't have it on your system.

  • Linux

    # install openssl
    sudo apt-get install libssl-dev
    # generate `cert.pem` and `key.pem`
    npm run generate-ssl
  • Windows: openssl is bundled with Git so that you can directly generate cert.pem and key.pem with following command in gitbash if you have Git installed.

    openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

    Then move the cert.pem and key.pem into the project root directory.

You can also setup https server with other solutions(like Express and Caddy) and set the ./dist as root directory.

Launch the server
  npm run startup

Once finished, open the browser and navigate to: https://localhost:8080 or https://your-server-ip:8080

LICENSE

Some samples for this repository are based on modifications of examples from Transformers.js(Apache-2.0) and MediaPipe(Apache-2.0).

Sample Source Model Model License
Background Removal Transformers.js RMBG-1.4 bria-rmbg-1.4
Image to text Transformers.js ViT-GPT2 Apache-2.0
Question Answering Transformers.js DistilBERT Apache-2.0
Summarization Transformers.js DistilBART CNN Apache-2.0
Phi3 WebGPU Transformers.js Phi-3-mini-4k MIT
LLM Gemma MediaPipe Gemma-2B Gemma

web-ai-showcase's People

Contributors

ningw101 avatar ibelem avatar gyagp avatar dvlp avatar rdower avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.