Skip to content

Latest commit

 

History

History
137 lines (101 loc) · 3.82 KB

README.md

File metadata and controls

137 lines (101 loc) · 3.82 KB

GoDoc Go Report Card Build Status Codecov License

Kai is a objection detection cloud services based on YOLO/Darknet.

Features

  • Backend on the YOLO/Darknet of golang binding
  • Convenient RESTful to use
  • support S3 download and upload
  • support Ftp download and upload

Precondition

  • nvidia-docker 2.0
  • CUDA
  • cudnn

Docker

docker pull yummybian/kai
sudo docker run --runtime nvidia -it --rm -p 8000:8000 -v /path/to/config.yaml:/kai-service/config.yaml yummybian/kai bash
or
sudo docker run --runtime nvidia -d --name kai -p 8000:8000 -v /path/to/config.yaml:/kai-service/config.yaml yummybian/kai 

Setting Up

First make sure you have go-yolo installed on your machine.

You can store jobs on memory or MongoDB. On your config.yaml file:

  • For MongoDB, set dbdriver: "mongo" and mongohost: "your.mongo.host"
  • For memory, just set dbdriver: "memory" and you're good to go.

Please be aware that in case you use memory, Kai will persist the data only while the application is running.

Finally download weight file from the darknet project into the root directory of kai.

Run!

$ make run

Running tests

Make sure you have a local instance of MongoDB running.

$ make test

Using the API

Creating a Job

In order to create a job you need to specify a HTTP or S3 address of a source and a S3 address for the destination.

Given a JSON file called job.json:

{
  "source": "http://www.example.com/example.jpg",
  "destination": "http://AWSKEY:[email protected]/DIRECTORY",
  "cate": 0
}

or

{
  "source": "http://AWSKEY:[email protected]/DIRECTORY/example.jpg",
  "destination": "http://AWSKEY:[email protected]/DIRECTORY",
  "cate": 0
}

Note: key cate 0 for image, 1 for video

Then, make a POST request to the API:

$ curl -X POST -H "Content-Type: application/json" -d @job.json  http://api.host.com/jobs
< HTTP/1.1 200 OK

Listing Jobs

$ curl -X GET http://api.host.com/jobs
< HTTP/1.1 200 OK
{
    "id": "7cJ5BtLwcFcQ8Vi8",
    "source": "http://AWSKEY:[email protected]/DIRECTORY/example.jpg",
    "destination": "http://AWSKEY:[email protected]/DIRECTORY",
    "mediaType": {
        "cate": 0,
        "name": "example",
        "container": "jpg"
    },
    "status": "created",
    "details": ""
}

Getting Job Details

With the Job ID:

$ curl -X GET http://api.host.com/jobs/7cJ5BtLwcFcQ8Vi8

Starting the job

With the Job ID:

$ curl -X GET http://api.host.com/jobs/7cJ5BtLwcFcQ8Vi8/start

Then you should request job details in order to follow the status of each step (downloading, processing, uploading).

Contributing

  1. Fork it
  2. Create your feature branch: git checkout -b my-awesome-new-feature
  3. Commit your changes: git commit -m 'Add some awesome feature'
  4. Push to the branch: git push origin my-awesome-new-feature
  5. Submit a pull request

License

This code is under Apache 2.0 License.