https://github.com/princejoogie/item-classifier-python
Item Classifier retraining code with Python
https://github.com/princejoogie/item-classifier-python
anaconda python tensorflow
Last synced: 2 months ago
JSON representation
Item Classifier retraining code with Python
- Host: GitHub
- URL: https://github.com/princejoogie/item-classifier-python
- Owner: princejoogie
- Created: 2021-04-29T02:40:32.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-22T11:47:04.000Z (about 4 years ago)
- Last Synced: 2025-06-03T21:16:48.758Z (about 1 year ago)
- Topics: anaconda, python, tensorflow
- Language: Python
- Homepage:
- Size: 29.8 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# item-classifier-python
A reusable library for classifying different objects
## Install python requirements with Anaconda
1. `conda create -n tf python=3.8.8`
2. `conda activate tf`
3. cd into the repository
4. `pip install -r requirements.txt`
## Getting the tick dataset
1. Obtain your dataset.
2. Extract the `dataset.zip` into `src/tf_files/dataset`
3. rename all files to .jpg with `dir | Rename-Item -NewName { $_.name -replace ".PNG",".jpg"}`
## Retrain and Conversion
1. `(Optional)` Start tensorboard
```{python}
tensorboard --logdir tf_files/training_summaries &
```
#### note that the "`^`" is an escape character and may vary with the terminal you're using. This works for command prompt in windows.
2. Run retrain script
```{python}
python -m scripts.retrain ^
--image_dir=tf_files/dataset ^
--model_dir=tf_files/models ^
--architecture=mobilenet_0.50_224 ^
--output_graph=tf_files/model_graph.pb ^
--output_labels=tf_files/model_labels.txt ^
--bottleneck_dir=tf_files/bottlenecks ^
--summaries_dir=tf_files/training_summaries/mobilenet_0.50_224 ^
--how_many_training_steps=400 ^
--learning_rate=0.001
```
3. `(Optional)` Quantize the graph for better performance in javascript
```{python}
python -m scripts.quantize_graph ^
--input=tf_files/model_graph.pb ^
--output=tf_files/quantized_model_graph.pb ^
--output_node_names=final_result ^
--mode=weights_rounded
```
4. Convert model into tensorflowjs format
```{python}
tensorflowjs_converter ^
--input_format=tf_frozen_model ^
--output_node_names=final_result ^
tf_files/quantized_model_graph.pb ^
tf_files/web
```
## Prediction
```{python}
python -m scripts.predict ^
--image=tf_files/dataset/your_image.jpg ^
--labels=tf_files/model_labels.txt ^
--graph=tf_files/model_graph.pb
```
The converted tensorflowjs model is in `tf_files/web` directory