# imagetools

This directory contains scripts generating input data file for paddle-mobile. The image data `g_test_image_1x3x224x224_banana` (used by `test/net/test_mobilenet.cpp`) of [http://mms-graph.bj.bcebos.com/paddle-mobile%2FmodelsAndImages.zip](http://mms-graph.bj.bcebos.com/paddle-mobile%2FmodelsAndImages.zip) is generated by this script.

## Generate Input

Edit script `img2nchw.py` as below according to your need:

```python
if __name__ == "__main__":
    # set paras
    input_image_path = 'banana.jpg'
    reshape_dict = {"n":1, "c":3, "h":48, "w":512}
    output_path = input_image_path.replace(input_image_path[-4:],
                                           "_" + "_".join([str(reshape_dict['n']),
                                                           str(reshape_dict['c']),
                                                           str(reshape_dict['h']),
                                                           str(reshape_dict['w']),
                                                           "nchw",
                                                           "float"],))
    channel_type = ChannelType.BGR
    mean_bgr = (103.94, 116.78, 123.68) # (0, 0, 0)
    pixel_scale = 0.017
```
