View the workshop video here!
Note: if you attended the workshop or cloned this repo before 18 September 2020, please type git pull
while in the project folder to pull the latest code in which the backend is completed and everything should be working!
The purpose of this repo is to help you get started with the basic tools 🔨 and code 💻 needed to follow along in the workshop. It will also serve as the single source of truth, hosting the latest version of our facemask 😷 detector workshop material 📚.
We hope that you will find great joy and meaning in our workshop! 😂 Consider giving this repo a star ⭐ if you found it helpful!
View the workshop video here!
This guide covers the installation of:
- Anaconda - a distribution of python which comes with a lot of data science packages 📦.
jupyter notebook
- a live python execution environment typically used for exploratory 🔍 data analysis.nodejs
andnpm
- nodejs is a js (javascript) runtime built on chrome's V8 engine 🚗 and npm is a package manager for nodejs.
You may find the detailed installation instructions for your operating system (Linux/Mac/Windows) via the links below. We know the instructions might look pretty lengthy but it won't take more than 20 minutes! 🙏🙏🙏
If you use a Windows machine, click here.
If you use a Mac, click here.
If you use Linux, click here.
Please only follow ONE of the installation guides e.g. if you're using Mac please don't follow the Linux guide by accident. We can't help you with troubleshooting issues otherwise.
Please post a GitHub issue on this repo if you encounter any difficulties!
We'd love to help you, so do include as much information that could help us such as:
- error logs,
- your operating system (Windows/Mac/Linux),
- your
python3 --version
, - the exact steps you took that led to the issue,
- etc.
Thank you 🙏
This is how the project is 🏘️🏗️structured🏢🏬. Do have a read to orient:angel: yourself.
.
├── backend/ <--- contains FastAPI server code
├── frontend/ <--- contains website server code (nextjs)
├── notebook/ <--- contains jupyter notebook code
├── linux.md
├── mac.md
├── README.md
└── windows.md
.
├── notebook/
├── data/ <--- contains our train and test data and labels
│ ├── test/
│ ├── test.csv
│ ├── train/
│ └── train.csv
├── facemask_workshop_participants.ipynb <--- the jupyter notebook you'll play with
├── history.pickle <--- our saved model training history
└── model/ <--- our saved keras model (facemask detector)
├── assets/
├── saved_model.pb
└── variables/
.
├── backend/
├── detector/
│ ├── config/
│ │ ├── classifiers <--- weights for non-DL face detector
│ │ ├── facenet <--- weights for DL face detector
│ │ └── keras_model/ <--- our saved keras model (facemask detector)
│ ├── detector.py <--- our detector class that utilizes the model
│ └── __init__.py
├── __init__.py
├── main.py <--- FastAPI server entrypoint
├── requirements.txt <--- specifies the project dependencies
└── run.sh <--- simple script to help run the FastAPI server
.
├── frontend/
├── components/
│ ├── cardDetectionLog/
│ ├── cardVideoFeed/
│ │ ├── Canvas.js <--- draws bounding box around your face
│ │ └── CardVideoFeed.js <--- video component
│ └── footerContent/
├── config.js <--- lets you configure the detection interval (fps)
├── package.json <--- specifies the project dependencies
├── pages/
│ ├── _app.js
│ └── index.js <--- website entrypoint
├── styles/
└── utils/
└── detector.js <--- contains functions to send API requests to backend
Follow the instructions below to get familiarized with the project repo. You may make reference to this section during the workshop itself to perform certain tasks 📖.
If you wish to access the incomplete pre-workshop code, type git checkout workshop
to switch to the workshop
branch (while in the project folder). To revert back to the master
branch containing the working code, type git checkout master
.
- Ensure you have the latest system packages.
- (For Windows/Linux) Open up terminal (wsl terminal for Windows) and type
sudo apt update && sudo apt upgrade
. - (For Mac) Open up terminal and type
brew update && brew upgrade
.
- (For Windows/Linux) Open up terminal (wsl terminal for Windows) and type
- Run
git clone --depth 1 https://github.com/geoboom/facemask-workshop.git
to clone this repo.- Troubleshooting: if you get a
git command not found
error, runsudo apt install git
first then try cloning the repo again.
- Troubleshooting: if you get a
- Run
ls
and you should see a folder calledfacemask-workshop
.
- In terminal, type
cd facemask-workshop
to navigate to the project's root folder. - In the root folder, navigate to the notebook subdirectory by typing
cd notebook
. - Type
conda activate base
to activate Anaconda's base environment. You should see(base)
beside your name in terminal. - Now run
jupyter notebook
(jupyter notebook --no-browser
if you're on windows) and this notebook folder should open in Jupyter Notebook on your browser.- If you're on windows, copy the url that looks like
http://127.0.0.1..token=..
ORhttp://localhost..token=..
displayed in the terminal and paste it in your browser. This is the url to your Jupyter Notebook. - Troubleshooting: if for some reason Jupyter Notebook in the browser does not show the files in
notebook/
folder, then go back to terminal and hit CTRL+C to stop the server. Once the server has stopped, runjupyter notebook --no-browser --notebook-dir=.
and try accessing it on the browser again.
- If you're on windows, copy the url that looks like
- Open up a new terminal and type
cd facemask-workshop
to navigate to the project's root folder. - In the root folder, navigate to the frontend subdirectory by typing
cd frontend
. - Type
npm install
to install the frontend project dependencies specified inpackage.json
. This might take a while so grab a coffee ☕. - Once the dependencies have finished installing, type
npm run dev
to run the website's server (nextjs
). - Visit
localhost:3000
in your browser to see the website live!
- Open up a new terminal and type
cd facemask-workshop
to navigate to the project's root folder. - In the root folder, navigate to the backend subdirectory by typing
cd backend
. - Type
python3 -m venv venv
to create apython3
virtual environment in the backend directory.- Troubleshooting: if you get an error regarding
pip
/ensurepip
/venv
, you most likely do not havepython3-venv
installed. To resolve this, runsudo apt install python3-venv
.
- Troubleshooting: if you get an error regarding
- Type
source venv/bin/activate
to activate this virtual environment. You should see(venv)
beside your name, indicating that thevenv
environment is activated. - Run
pip install -r requirements.txt
to install the dependencies to this virtual environment, specified byrequirements.txt
. This might take a while so grab a coffee ☕. It is strongly advised that you runpip install --upgrade pip
first.- Troubleshooting: if you get "ERROR: Could not find a version that satisfies the requirement opencv-contrib-python=4.4.0.42..." attempting this step, fret not. Just run
git pull
to fetch the latest changes (I most likely updated the repo after you cloned it) and re-do step 5.
- Troubleshooting: if you get "ERROR: Could not find a version that satisfies the requirement opencv-contrib-python=4.4.0.42..." attempting this step, fret not. Just run
- Once dependencies have finished installing, type
./run.sh
to run the FastAPI server and hit enter.
Name | Role | Github |
---|---|---|
Jet | NUS Statistics Society Workshop Director | https://github.com/jetnew |
Rama | Presenter, guide writing, and material prep | https://github.com/ramaven |
Georgie | Presenter, guide writing, and material prep | https://github.com/geoboom |
Dataset for masked/no-masked.