Automatic fine-tune in production
After running the system for a while, we will have some user-labeled images. We will create a fine-tune process to automatically run every day and fine-tune the latest model with new data.
Let's create a file named finetune.py
in the scripts folder.
Loading the user-labeled data
First, we will add the code to download all user-labeled images from the production server:
import tensorflow as tf import os import json import random import requests import shutil from scipy.misc import imread, imsave from datetime import datetime from tqdm import tqdm import nets, models, datasets def ensure_folder_exists(folder_path): if not os.path.exists(folder_path): os.mkdir(folder_path) return folder_path def download_user_data(url, user_dir, train_ratio=0.8): response = requests.get("%s/user-labels" % url) data = json.loads(response.text) if not os.path.exists(user_dir)...