During my internship in an AI Tech Startup in Singapore's Block 71, I've developed a FAST API based heatmap dashboard which would be integrated into the main UI of the actual dashboard for effective object tracking and activity classification of construction equipments such as excavators in construction sites in Singapore.
A) The Data Folder contains all the data files that is needed for the code.
B) The Images Folder contains all the images that are needed for the application. Use this and copy the filepath into my code.
C) The Code Folder contains all the codes needed to develop the FAST API application using Python. Change the filepath of the .csv file under the Data Folder to the path where you've downloaded it in your local drive in my code. Below are the descriptions of each file:
- main_individual_heatmap_functions.py: Can call in a specific function only to display either people or machinery class for each camera desired. This is the pure Python file for my code.
- main_automated_all_camera_heatmaps.py: Displays people and machinery classes for all cameras 9-12 in the .csv file simultaneously in real time. This is the pure Python file for my code.
- anurag_code_for_main_automated_all_camera_heatmaps.py: This performs the same as main_automated_all_camera_heatmaps.py, with the only difference being that I've integrated FAST API into the application for live viewing now. You can view snapshots of each activity class for each camera for a specific date and time.
- anurag_refactored_code_for_main_automated_all_camera_heatmaps.py: This performs the same function as anurag_code_for_main_automated_all_camera_heatmaps.py, with the only difference being the runtime, which is much faster now as it only displays live heatmap videos only.
Follow these steps to install FAST API in your laptop and get it running in your server:
Step 1: Install FAST API Library
pip install fastapi
Step 2: Install Uvicorn
pip install "uvicorn[standard]"
pip install uvicorn # Can do this also
python -m pip install fastapi uvicorn[standard] # This can be done too
Here is an example of a FAST API application:
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
Step 3: Get FAST API To Run In Your Server
uvicorn main:app --reload # Here, main is your main.py file and app is the name of your FAST API instane that is called as FastAPI ()
Step 4: Alternatively you can install FAST API using this command too:
pip install "fastapi[all]" #do not have to manually install uvicorn then
Step 5: Visualize FAST API running on your server
http://127.0.0.1:8000 # Can visualize your FAST API running here
http://127.0.0.1:8000/docs #FAST API web application to visualize your POST, GET, PUT and DELETE commands which serves as a mini-dashboard for easy visualization
http://127.0.0.1:8000/redoc # Alternatively, can use this one too