readme and minor

This commit is contained in:
Dimitrii Lopanov
2020-10-16 12:52:56 +03:00
parent e5d170ef8b
commit 7f94c3bdcc
3 changed files with 190 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

View File

@@ -35,4 +35,187 @@ Build and run program
go build main.go && ./main --configFile=yolov3.cfg --weightsFile=yolov3.weights --port 8090
```
@todo
After server started check if REST-requests works. We provide cURL-based example
```shell
curl -F 'image=@sample.jpg' 'http://localhost:8090/detect_objects'
```
Servers response should be something like this:
```json
{
"net_time": "43.269289ms",
"overall_time": "43.551604ms",
"num_detections": 44,
"detections": [
{
"class_id": 7,
"class_name": "truck",
"probability": 49.51231,
"start_point": {
"x": 0,
"y": 136
},
"end_point": {
"x": 85,
"y": 311
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 36.36933,
"start_point": {
"x": 95,
"y": 152
},
"end_point": {
"x": 186,
"y": 283
}
},
{
"class_id": 7,
"class_name": "truck",
"probability": 48.417683,
"start_point": {
"x": 95,
"y": 152
},
"end_point": {
"x": 186,
"y": 283
}
},
{
"class_id": 7,
"class_name": "truck",
"probability": 45.652023,
"start_point": {
"x": 694,
"y": 178
},
"end_point": {
"x": 798,
"y": 310
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 76.8402,
"start_point": {
"x": 1,
"y": 145
},
"end_point": {
"x": 84,
"y": 324
}
},
{
"class_id": 7,
"class_name": "truck",
"probability": 25.592052,
"start_point": {
"x": 107,
"y": 89
},
"end_point": {
"x": 215,
"y": 263
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 99.87823,
"start_point": {
"x": 511,
"y": 185
},
"end_point": {
"x": 748,
"y": 328
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 99.819336,
"start_point": {
"x": 261,
"y": 189
},
"end_point": {
"x": 427,
"y": 322
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 99.64055,
"start_point": {
"x": 426,
"y": 197
},
"end_point": {
"x": 539,
"y": 311
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 74.56263,
"start_point": {
"x": 692,
"y": 186
},
"end_point": {
"x": 796,
"y": 316
}
},
{
"class_id": 2,
"class_name": "car",
"probability": 72.79756,
"start_point": {
"x": 388,
"y": 206
},
"end_point": {
"x": 437,
"y": 276
}
},
{
"class_id": 1,
"class_name": "bicycle",
"probability": 72.27595,
"start_point": {
"x": 178,
"y": 270
},
"end_point": {
"x": 268,
"y": 406
}
},
{
"class_id": 0,
"class_name": "person",
"probability": 97.30075,
"start_point": {
"x": 143,
"y": 135
},
"end_point": {
"x": 268,
"y": 343
}
}
]
}
```

View File

@@ -47,10 +47,9 @@ func main() {
// DarknetResp Response
type DarknetResp struct {
NetTime string `json:"net_time"`
OverallTime string `json:"overall_time"`
NumDetections int `json:"num_detections"`
Detections []*DarknetDetection `json:"detections"`
NetTime string `json:"net_time"`
OverallTime string `json:"overall_time"`
Detections []*DarknetDetection `json:"detections"`
}
// DarknetDetection Information about single detection
@@ -106,10 +105,9 @@ func detectObjects(n *darknet.YOLONetwork) func(w http.ResponseWriter, req *http
}
resp := DarknetResp{
NetTime: fmt.Sprintf("%v", dr.NetworkOnlyTimeTaken),
OverallTime: fmt.Sprintf("%v", dr.OverallTimeTaken),
NumDetections: len(dr.Detections),
Detections: []*DarknetDetection{},
NetTime: fmt.Sprintf("%v", dr.NetworkOnlyTimeTaken),
OverallTime: fmt.Sprintf("%v", dr.OverallTimeTaken),
Detections: []*DarknetDetection{},
}
for _, d := range dr.Detections {