This project is an implementation of the CloudRaft assignment for creating a backend application with a pre-trained model for image classification. The application allows users to upload images, classify them into categories (simulating dog breed classification), and query the uploaded images.
-
GET /model
- Retrieves information about the model.
- Response:
{ "name": "MobileNet (simulating dog breed classifier)", "version": "1.0", "description": "Pre-trained model for image classification" }
-
POST /img
- Accepts an image and returns its classification.
- Request: Form-data with key "image" and file upload.
- Response:
{ "category": "labrador", "uid": "1519151980" }
-
GET /images
- Returns all uploaded images with their UIDs and categories.
- Response:
[ { "uid": "6569841", "category": "labrador" }, ]
-
POST /img/{uid}
- Downloads the image that matches the provided UID.
- Response: Image file download.
-
GET /categories
- Returns all categories with the number of images in each.
- Response:
{ "labrador": "2", "bulldog": "12" }
- Node.js (v18.17.0 or later)
- npm (comes with Node.js)
-
Clone the repository:
git clone https://github.com/sagnik3788/CloudRaft-assignment.git cd CloudRaft-assignment
-
Install dependencies:
npm install
-
Create an
uploads
directory:mkdir uploads
-
Start the server:
node app.js
The server will start running on http://localhost:3000
.
-
Build the Docker image:
docker build -t cloudraft-assignment .
-
Run the Docker container:
docker run -p 3000:3000 cloudraft-assignment
The application will be accessible at http://localhost:3000
.
- Node.js
- Express.js
- TensorFlow.js
- MobileNet (pre-trained model)
- Multer (for file uploads)
- Docker (for containerization)
- For simplicity using local storage to to store the downloaded images but in prod should use s3 bucket
- Images will be stored within the Docker container's filesystem.
- Data will be lost when the container is removed.
- To persist data and access it from the host system, we should mount a host directory to the container's
uploads
directory