<commit_before>#### Install Tensorflow
Based on: https://www.tensorflow.org/install/pip
```
$ cd data
$ sudo pip3 install -U virtualenv
$ virtualenv --system-site-packages -p python3 ./venv
$ source ./venv/bin/activate
$ pip install --upgrade pip
$ pip install --upgrade tensorflow==1.12.0
$ pip install --upgrade tensorflow-hub==40.6.2
$ pip install --upgrade requests
$ pip install --upgrade pillow


$ deactivate # run when finished
```

#### Download pictures from Pola
```
$ cd data
$ python get_ai_pics.py $SHARED_SECRET Pola_ai
```

#### Retrain MobileNet v2 model
# https://raw.githubusercontent.com/tensorflow/hub/master/examples/image_retraining/retrain.py
```
$ rm -rf model bottleneck pola_retrained.pb pola_retrained_labels.txt pola_retrained.tflite

python retrain.py \
  --bottleneck_dir=bottleneck \
  --how_many_training_steps=500000 \
  --model_dir=model \
  --output_graph=pola_retrained.pb \
  --output_labels=pola_retrained_labels.txt \
  --tfhub_module=https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 \       --image_dir=Pola_ai \
  --validation_percentage=15

# test retrained model  
$ python label_image.py \
  --graph=pola_retrained.pb \
  --labels=pola_retrained_labels.txt \
  --image=ludwik.jpg
```

#### Convert model to tflite
```
toco \
  --graph_def_file=pola_retrained.pb \
  --input_format=TENSORFLOW_GRAPHDEF \
  --output_format=TFLITE \
  --output_file=pola_retrained.tflite \
  --inference_type=FLOAT \
  --input_type=FLOAT \<commit_msg>proper tensorflow hub version<commit_after>#### Install Tensorflow
Based on: https://www.tensorflow.org/install/pip
```
$ cd data
$ sudo pip3 install -U virtualenv
$ virtualenv --system-site-packages -p python3 ./venv
$ source ./venv/bin/activate
$ pip install --upgrade pip
$ pip install --upgrade tensorflow==1.12.0
$ pip install --upgrade tensorflow-hub==0.1.1
$ pip install --upgrade requests
$ pip install --upgrade pillow


$ deactivate # run when finished
```

#### Download pictures from Pola
```
$ cd data
$ python get_ai_pics.py $SHARED_SECRET Pola_ai
```

#### Retrain MobileNet v2 model
# https://raw.githubusercontent.com/tensorflow/hub/master/examples/image_retraining/retrain.py
```
$ rm -rf model bottleneck pola_retrained.pb pola_retrained_labels.txt pola_retrained.tflite

python retrain.py \
  --bottleneck_dir=bottleneck \
  --how_many_training_steps=20000 \
  --model_dir=model \
  --output_graph=pola_retrained.pb \
  --output_labels=pola_retrained_labels.txt \
  --tfhub_module=https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 \       --image_dir=Pola_ai \
  --validation_percentage=15 \
  --print_misclassified_test_images

# test retrained model  
$ python label_image.py \
  --graph=pola_retrained.pb \
  --labels=pola_retrained_labels.txt \
  --image=ludwik.jpg
```

#### Convert model to tflite
```
toco \
  --graph_def_file=pola_retrained.pb \
  --input_format=TENSORFLOW_GRAPHDEF \
  --output_format=TFLITE \
  --output_file=pola_retrained.tflite \
  --inference_type=FLOAT \
  --input_type=FLOAT \
{'fraction_non_alphanumeric': 0.13278688524590163, 'fraction_numerical': 0.017049180327868854, 'mean_word_length': 3.9289176090468496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4248231', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1083, 'n_words': 194}