This example shows how to:
- Define a CNN by subclassing the tf.keras.Model class
- Train the model (from scratch or loading an existing model)
- Visualize training history
- Load & use a dataset from Tensorflow & Hugging Face
- Load & Save models using SavedModel & SafeTensors formats
- Inference
Create Virtual environment & install dependencies
python3.11 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
Activate Virtual environment
source venv/bin/activate
Deactivate Virtual environment
deactivate
--save_freq=0 if you don't want to save the model
Training from Scratch
python train.py --epochs=10 --save_freq=10 --batch_size=64
Training loading previous version
python train.py --epochs=10 --save_freq=5 --load --batch_size=64
Loads all images inside the selected folder and makes predictions.
images inside sample's folder have different sizes
python inference.py --img_folder="samples"
-
Datasets
-
Save & Load Models
-
Model Definition