DermatoVisionAPI is a RESTful API for dermatological image analysis. It focuses on predicting whether a skin condition is cancerous or not based on input images.
- Cancer Detection: Given an input image, the API predicts whether the skin condition is cancerous or not.
- Model Storage: The API provides functionality to load and manage the machine learning model used for prediction.
- Input Validation: Input images are validated to ensure they meet the necessary criteria before prediction.
- Node.js (v20.12.2)
- Google Cloud SDK
- Docker
- A Google Cloud Project
-
Clone the repository:
git clone https://github.com/chrystalio/DermatoVisionAPI.git
-
Change the directory:
cd DermatoVisionAPI
-
Install dependencies:
npm install
-
[OPTIONAL] Upload your model to a Google Cloud Storage bucket. The model files are inside the
model
directory. -
If you prefer to load the model data from the local directory, you can refer to it directly from the
model
directory. -
Create a new service account in Google Cloud and assign the
Cloud Datastore Owner
role. -
Download the JSON key for the service account, store it inside the
config
folder, and rename it toservice.json
. -
Ensure your
config/service.json
contains your Google Cloud credentials. -
Enable Firestore API.
-
Open
Google Cloud Console → Firestore
, then clickCreate Database
. -
Choose
Native Mode
, select your region, and create the database. -
Set up your environment variables. Create a
.env
file in the root directory and add the following:APP_ENV=local MODEL_URL=https://storage.googleapis.com/your-bucket/model.json GCLOUD_PROJECT_ID={projectID} GCLOUD_KEY_FILE=config/service.json
Or if you are not uploading the model to a cloud storage bucket, set it like this:
APP_ENV=local MODEL_URL=./model/model.json GCLOUD_PROJECT_ID={projectID} GCLOUD_KEY_FILE=config/service.json
-
Start the server:
npm run start:dev
-
Build the Docker image:
docker build -t {region}-docker.pkg.dev/{projectID}/dermatovision-image/dermatovision-api:v1 .
-
Create Docker Repository inside Artifact Registry
gcloud artifacts repositories create dermatovision-image --repository-format=docker --location={region} --description="DermatovisionAPI Docker Repository" --project={projectID}
-
Authenticate Docker to use the Artifact Registry repository
gcloud auth configure-docker {region}-docker.pkg.dev
-
Push the Docker image to the Artifact Registry repository
docker push {region}-docker.pkg.dev/{projectID}/dermatovision-image/dermatovision-api:v1
-
Deploy it on Cloud Run
gcloud run deploy DermatoVisionAPI --image={region}-docker.pkg.dev/{projectID}/dermatovision-image/dermatovision-api:v1 --region={region} --allow-unauthenticated
If you encounter issues with permissions or environment variables, ensure that:
Your Google Cloud credentials are correctly set up in the config/credentials.json file. The environment variables in the .env file are correctly configured. The IAM roles for your service account have the necessary permissions.
- Thanks to the Dicoding team for providing the machine learning model.
- Special thanks to the Google Cloud Platform for providing the infrastructure.
Make sure to replace placeholder values (like `{projectID}`, `your-bucket`) with the actual values for your project. Additionally, include any other specific setup instructions or dependencies unique to your project.