Skip to content

Hassi34/Skin-Cancer-Detector-TF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Skin Cancer Detector

Typing SVG

Typing SVG

License Last Commit Code Size Repo Size License

About Web-App

Overview

This project contains the implementation of REST API and WEB APP empowered by Vision AI to detect and make the prediction for potential risk of skin cancer while provided with the image of skin.The model is trained using TensorFlow. The REST API services are being distributed through docker image. You can pull the image from Docker Hub.The image comes as the production ready with unit tests and standard algorithm implemented which can be used to expose the REST API to the web.
Following are the major contents to follow, you can jump to any section:

  1. Run Locally
  2. Model Training
  3. REST API

Run Locally

Clone the project

  git clone https://github.com/Hassi34/Skin-Cancer-Detector-TF.git

Go to the project directory

  cd Skin-Cancer-Detector-TF

Install dependencies

  pip install -r requirements.txt

Start the server

  streamlit run app.py

REST API

To run the following sequence of commands, make sure you have the docker installed on your system.

Pull Image from Docker Hub

In case you have not already pulled the image from the Docker Hub, you can use the following command:

docker pull hassi34/skincancer-detector

Docker Container

Now once you have the docker image from the Docker Hub, you can now run the following commands to test and deploye the container to the web

  • Run a Docker Container
    Check all the available images:
docker images

Use the following command to run a docker container on your system:

docker run --name <CONTAINER NAME> -p 80:80 -d <IMAGE NAME OR ID>

Check if the container is running:

docker ps

If the container is running, then the API services will be available on all the network interfaces
Type localhost in the brower and see if you get the success message from the API service.

  • Perform Unit Tests
    After when the API services are up and running, run the following command on the termial to perform the unit test:
docker exec -it <CONTAINER NAME OR ID> pytest

Make an API Request

Use the following script as a reference to make a REST API request:

import requests
import base64

IN_IMG_PATH = "in.jpg" # You can give any name with the right extension
OUT_IMG_PATH = "out.jpg" 
ENDPOINT = "http://127.0.0.1/predict"

def decodeImage(base64_str, OUT_IMG_PATH):
    imgdata = base64.b64decode(base64_str)
    with open(OUT_IMG_PATH, 'wb') as f:
        f.write(imgdata)
        f.close()


def encodeImageIntoBase64(IN_IMG_PATH):
    with open(IN_IMG_PATH, "rb") as f:
        return base64.b64encode(f.read())

if __name__ == '__main__':

    BASE64_STR = encodeImageIntoBase64(IN_IMG_PATH).decode("utf-8")
    response = requests.post(ENDPOINT, json={"base64_str":BASE64_STR})
    if response.status_code == 200:
        response = response.json()
        print(response)
        decodeImage(response["base64_str"], OUT_IMG_PATH)
    else :
        print(response)

Thank you for visiting πŸ™ I hope you find this project useful

πŸ“ƒ License

MIT Β© Hasanain

Copyright Β© 2023 Hasanain
Let's connect on LinkedIn

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published