Skip to content

Commit

Permalink
Merge pull request #291 from awslabs/ssd-examples
Browse files Browse the repository at this point in the history
public domain image examples for SSD outputs
  • Loading branch information
aaronmarkham authored Jan 22, 2018
2 parents 2432880 + 8f3be03 commit 6d618ad
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 76 deletions.
Binary file added examples/ssd/3dogs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 33 additions & 76 deletions examples/ssd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ The inference service would return the response in the format - '[(object_class,

## Step 1 - Download the pre-trained SSD Model

You will need the model files to use for the export. Check this example's directory in case they're already downloaded. Otherwise, you can `curl` the files or download them via your browser:

```bash
wget https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json
wget https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params
curl -O https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json
curl -O https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params
```

or

Use these links to download the Symbol and Params files:
Alternatively, use these links to download the Symbol and Params files via your browser:
1. <a href="https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json" download>resnet50_ssd_model-symbol.json</a>
2. <a href="https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params" download>resnet50_ssd_model-0000.params</a>

Expand Down Expand Up @@ -137,88 +137,45 @@ Awesome! we have successfully exported a pre-trained MXNet model, extended MMS w

## Step 7 - Test sample inference

Let us try the inference server we just started. Open another terminal on the same host. Download a sample image.
Let us try the inference server we just started. Open another terminal on the same host. Download a sample image, or try any jpeg image that contains the one or more of the object classes mentioned earlier: 'aeroplane', 'bicycle', 'bird', 'boat', etc...

```bash
wget https://www.dphotographer.co.uk/users/21963/thm1024/1337890426_Img_8133.jpg
```
You can also use this image of three dogs on a beach.
![3 dogs on beach](3dogs.jpg)

Use curl to make a prediction call by passing the downloaded image as input to the prediction request.

```bash
curl -X POST http://127.0.0.1:8080/SSD/predict -F "data=@1337890426_Img_8133.jpg"
curl -X POST http://127.0.0.1:8080/ssd/predict -F "data=@3dogs.jpg"
```

You can expect the response similar to below. The output format is `[(object_class, xmin, ymin, xmax, ymax)]`.
Where, xmin, ymin, xmax and ymax are the bounding box coordinates of the detected object.

```
{
"prediction": [
[
"person",
494,
153,
702,
630
],
[
"person",
108,
108,
351,
591
],
[
"dog",
306,
446,
468,
530
],
[
"car",
9,
166,
96,
245
],
[
"person",
826,
127,
1008,
601
],
[
"person",
480,
177,
511,
253
],
[
"person",
555,
175,
581,
242
],
[
"person",
514,
177,
547,
250
],
[
"person",
62,
334,
185,
467
"prediction": [
[
"dog",
399,
128,
570,
290
],
[
"dog",
278,
196,
417,
286
],
[
"cow",
205,
116,
297,
272
]
]
]
}
```

Expand All @@ -228,11 +185,11 @@ For better visualization on the input and how we can use the inference output, s

Input Image

![Street Input Image](https://s3.amazonaws.com/model-server/models/resnet50_ssd/street.jpg)
![Street Input Image](dogs-before.jpg)

Output Image

![Street Output Image](https://s3.amazonaws.com/model-server/models/resnet50_ssd/street_output.jpg)
![Street Output Image](dogs-after.jpg)


# References
Expand Down
Binary file added examples/ssd/dogs-after.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/ssd/dogs-before.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions examples/ssd/example_outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# SSD Example Outputs

### Dog Beach

![dog beach](https://farm9.staticflickr.com/8184/8081332083_3a5c242b8b_z_d.jpg)
```bash
curl -o dogbeach.jpg https://farm9.staticflickr.com/8184/8081332083_3a5c242b8b_z_d.jpg
curl -X POST http://127.0.0.1:8080/ssd/predict -F "data=@dogbeach.jpg"
{
"prediction": [
[
"person",
203,
213,
248,
347
],
[
"dog",
334,
175,
403,
235
],
[
"person",
109,
211,
144,
291
],
[
"person",
529,
31,
562,
103
],
[
"person",
155,
12,
189,
98
],
[
"horse",
465,
3,
527,
40
],
[
"person",
51,
372,
96,
427
],
[
"dog",
80,
56,
131,
96
],
[
"person",
70,
89,
96,
155
],
[
"cow",
292,
188,
344,
231
],
[
"dog",
294,
186,
349,
231
]
]
}
```

### 3 Dogs on Beach
![3 dogs on beach](https://farm9.staticflickr.com/8051/8081326814_64756479c6_z_d.jpg)
```bash
curl -o 3dogs.jpg https://farm9.staticflickr.com/8051/8081326814_64756479c6_z_d.jpg
curl -X POST http://127.0.0.1:8080/ssd/predict -F "data=@3dogs.jpg"
{
"prediction": [
[
"dog",
399,
128,
570,
290
],
[
"dog",
278,
196,
417,
286
],
[
"cow",
205,
116,
297,
272
]
]
}
```
### Sailboat
![sailboat](https://farm9.staticflickr.com/8316/7990362092_84a688a089_z_d.jpg)
```bash
curl -o sailboat.jpg https://farm9.staticflickr.com/8316/7990362092_84a688a089_z_d.jpg
curl -X POST http://127.0.0.1:8080/ssd/predict -F "data=@sailboat.jpg"
{
"prediction": [
[
"boat",
160,
87,
249,
318
]
]
}
```

0 comments on commit 6d618ad

Please sign in to comment.