├── .gitignore ├── License.txt ├── README.md ├── Training_and_converting_to_js.ipynb ├── index.html └── static ├── classifier.css └── classifier.js /.gitignore: -------------------------------------------------------------------------------- 1 | weights/ -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the \"License\"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | https://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an \"AS IS\" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A cat dog image classifier deployed client side using javascript 2 | 3 |  4 | 5 | # Instructions 6 | 1. Train a keras classifier and save its weights 7 | 2. install `tensorflowjs` python library 8 | ```bash 9 | pip install tensorflowjs 10 | ``` 11 | 3. Use tensorflowjs converter tool to convert h5 weights to js format. 12 | ```bash 13 | tensorflowjs_converter --input_format=keras ./model.h5 ./jsweights 14 | ``` 15 | * Make sure the .h5 weights location is correct and also destination path exists. 16 | 17 | ### After running above command you will see `model.json` and `.bin` files, tensorflowjs converter dumps model architecture in `model.json` and it's weights in `.bin` files. 18 | 19 | # setup 20 | * Place your converted weights inside `weights` folder 21 | 22 | * Open `classifier.js` and update `model.json` path according to your weights folder 23 | 24 | * After everything is setup up perfectly run below command inside the directory. 25 | 26 | ```bash 27 | python3 -m http.server 28 | ``` 29 | 30 | * navigate to [localhost](http:127.0.0.1:8000) 31 | 32 | # Output 33 | 34 |  35 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |