Giter Club home page Giter Club logo

webservice-object-detection-from-scratch's Introduction

download project with git clone

git clone

Usage

download all dependencies

npm install

build project

npm run build

run project

npm start

Introduction

  • The project is a simple web application that allows users to detect the car in the video.
  • The user can upload a video and the application will detect the car in the video.

Setup

  • The project is built with React, Node.js, and Express.js.

  • Base start step 1: Create a project folder and setup npm.

mkdir my-project && cd my-project
npm init -y

step 2: Install Webpack.

npm i --save-dev webpack webpack-cli webpack-dev-server

step 3: Install Bootstrap version 5.3

npm i --save bootstrap @popperjs/core

step 4: Install additional dependencies.

npm i --save-dev autoprefixer css-loader postcss-loader sass sass-loader style-loader
  • Project structure
mkdir {dist,src,src/js,src/scss}
touch dist/index.html src/js/main.js src/scss/styles.scss webpack.config.js
my-project/
├── dist/
│   └── index.html
├── src/
│   ├── js/
│   │   └── main.js
│   └── scss/
│       └── styles.scss
├── package-lock.json
├── package.json
└── webpack.config.js
  • Configuration Webpack
const miniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require('path')
const fs = require('fs')


// get all the folder
const entryPoints = {};
const srcDirs = fs.readdirSync('./src', { withFileTypes: true });
const srcSubdirs = srcDirs.filter(dirent => dirent.isDirectory());

console.log(srcSubdirs)
// [
//   Dirent { name: 'assets', path: './src', [Symbol(type)]: 2 },
//   Dirent { name: 'js', path: './src', [Symbol(type)]: 2 },
//   Dirent { name: 'scss', path: './src', [Symbol(type)]: 2 }
// ]
srcSubdirs.forEach(dir => {
  const dirPath = path.join(__dirname, 'src', dir.name);
  const files = fs.readdirSync(dirPath);
  if (dir.name !== 'assets') {
    files.forEach(file => {
      const entryName = file.replace(/\..+$/, '');
      entryPoints[`${dir.name}\/${entryName}`] = path.join(dirPath, file);
      // }
    }); 
  }
})
console.log(entryPoints)

module.exports = {
  entry: entryPoints,
  plugins: [
    new miniCssExtractPlugin(
      {
        filename: '[name].css'
      }
    ),
    new CopyWebpackPlugin(
      {
        patterns:[
          {from: "node_modules/onnxruntime-web/dist/*.wasm",to  : "[name][ext]"},
        ]
      }
    )
  ],
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
    assetModuleFilename: "assets/img/icons/[name][ext]",
    library: {
      
      type: "umd"
    }
  },
  devServer: {
    static: path.resolve(__dirname, 'public'),
    port: 8080,
    hot: true
  },
  module: {
    rules: [
      {
        test: /\.(scss)$/,
        use: [
          {
            // loader: 'style-loader',
            // Extracts CSS for each JS file that includes CSS
            loader: miniCssExtractPlugin.loader
          },
          {
            loader: 'css-loader'
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                plugins: () => [
                  require('autoprefixer')
                ]
              }
            }
          },
          {
            loader: 'sass-loader'
          }
        ]
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        include: path.resolve(__dirname, "src"),
        type: 'asset/resource',
        generator: {
          filename: "assets/img/icons/[name][ext]",
        }
      },
      {
        test: /\.css$/,
        use: [{ loader: 'style-loader' }, { loader: 'css-loader' }]
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: 'html-loader',
            options: { minimize: true }
          }
        ]
      },
      { test: /\.ts$/, loader: "ts-loader" },  
      { test: /\.node$/, use: "node-loader"}
    ]
  }
}

webservice-object-detection-from-scratch's People

Contributors

minhanh01bg avatar

Watchers

 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.