README.md 1.2 KB
Newer Older
R
Renwb1991 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
A demo to show converting caffe models trained on 'imagenet' using caffe2fluid

---

# How to use

1. Prepare python environment

2. Download caffe model to "models.caffe/xxx" which contains "xxx.caffemodel" and "xxx.prototxt"

3. Convert the Caffe model to Fluid model
    - generate fluid code and weight file
        ```python convert.py alexnet.prototxt \
        --caffemodel alexnet.caffemodel \
        --data-output-path alexnet.npy \
        --code-output-path alexnet.py
        ```

    - save weights as fluid model file
        ```
        python alexnet.py alexnet.npy ./fluid
        ```

4. Do inference
    ```
    python infer.py infer ./fluid data/65.jpeg
    ```

5. convert model and do inference together
   ```
    bash ./tools/run.sh alexnet ./models.caffe/alexnet ./models/alexnet
    ```
    * Assume the Caffe model is stored in '*./models.caffe/alexnet/alexnet.prototxt|caffemodel*'
    * converted model will be stored as '*./models/alexnet/alexnet.py|npy*'

6. test the difference with caffe's results(need pycaffe installed)
   ```
    bash ./tools/diff.sh resnet
    ```
    * Make sure your caffemodel stored in '*./models.caffe/resnet*'
    * The results will be stored in '*./results/resnet.paddle|caffe*'