README.md 1.2 KB
Newer Older
1
A demo to show converting caffe models trained on 'imagenet' using caffe2fluid
W
wanglong03 已提交
2 3 4 5 6

---

# How to use

7 8 9 10 11 12
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
13
        ```python convert.py alexnet.prototxt \
14 15 16
        --caffemodel alexnet.caffemodel \
        --data-output-path alexnet.npy \
        --code-output-path alexnet.py
17
        ```
18 19

    - save weights as fluid model file
20 21 22
        ```
        python alexnet.py alexnet.npy ./fluid
        ```
23 24

4. Do inference
25 26 27
    ```
    python infer.py infer ./fluid data/65.jpeg
    ```
28 29

5. convert model and do inference together
30 31 32 33 34
   ```
    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*'
35 36

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