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:AWSSECRET@BUCKET.s3.amazonaws.com/DIRECTORY",
"cate": 0
}
or
{
"source": "http://AWSKEY:AWSSECRET@BUCKET.s3.amazonaws.com/DIRECTORY/example.jpg",
"destination": "http://AWSKEY:AWSSECRET@BUCKET.s3.amazonaws.com/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:AWSSECRET@BUCKET.s3.amazonaws.com/DIRECTORY/example.jpg",
"destination": "http://AWSKEY:AWSSECRET@BUCKET.s3.amazonaws.com/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
- Fork it
- Create your feature branch:
git checkout -b my-awesome-new-feature
- Commit your changes:
git commit -m 'Add some awesome feature'
- Push to the branch:
git push origin my-awesome-new-feature
- Submit a pull request
License
This code is under Apache 2.0 License.