/Ocean-CIDAI-Pigs

Primary LanguagePythonMIT LicenseMIT

Ocean CIDAI Pigs

This repository contains the needed code to publish a pig detector in an Ocean Protocol marketplace.

Instructions to build the Docker image:

  1. Clone the repo:

    git clone https://github.com/edgarGracia/Ocean-CIDAI-Pigs.git
    cd Ocean-CIDAI-Pigs
    
  2. Download the model and configuration from the repo releases and place it on model/. E.g.

    wget https://github.com/edgarGracia/Ocean-CIDAI-Pigs/releases/download/pigs_0_all_det2/Base-RCNN-FPN.yaml -P model/
    wget https://github.com/edgarGracia/Ocean-CIDAI-Pigs/releases/download/pigs_0_all_det2/config.yaml -P model/
    wget https://github.com/edgarGracia/Ocean-CIDAI-Pigs/releases/download/pigs_0_all_det2/model.pth -P model/
    
  3. Build the Docker image:

    docker build -t <docker_user>/<repo_name>:<image_tag> .
    

Test the algorithm locally

  1. Create the test directories:

    mkdir -p test/data/inputs
    mkdir -p test/data/outputs
    mkdir -p test/data/inputs/1234
    
  2. Copy the test data. It must be a zip file with images inside:

    cp /path/to/images.zip test/data/inputs/1234/0

  3. Run the previously created docker image or one from the Docker Hub:

    docker run --rm \
        -v "$(pwd)/test/data/inputs":/data/inputs \
        -v "$(pwd)/test/data/outputs":/data/outputs \
        -v "$(pwd)/entry_point.sh":/data/transformations/algorithm \
        -e DIDS='["1234"]' \
        <docker_image> bash /data/transformations/algorithm
    
  4. The output data should be saved in data/outputs/output.zip

Publish the algorithm on an Ocean Protocol marketplace (E.g. Pontus-X)

  1. Push the Docker image to Docker Hub:

    docker push <docker_user>/<repo_name>:<image_tag>

  2. Go to the marketplace and publish an asset:

    • Under "Metadata":
      • Set the "Asset Type" to "Algorithm"
      • In the "Docker Image" field select "Custom" and set the name of the previously pushed image
      • In the "Docker Image Entrypoint" field set "bash $ALGO"
    • Under "Access":

The published Docker images can be found at: https://hub.docker.com/repository/docker/egracia/ocean_cidai_pigs/