PrediBajk
The repository contains the following scripts:
-
download_images.sh
: given an inputtsv
file with URL in the first column, download the images, resize them to height 480px, save them asjpg
s, and print the outputtsv
with the image path prepended as the first column. -
model_train.py
: train a model using an EfficientNetV2 backbone. The trained is saved as Keras model inSavedModel
format. The script has the following options:--augment
(defaultflip,rotate,scale,colors
): augmentation operations to apply to the training data--batch_size
(default8
): batch size to use; 8 works on a 16GB GPU with a small variant of EfficientNetV2, 4 works on a 24GB GPU with a medium EfficientNetV2--data_classes
(defaultall
): which classes from the input data file to predict, orall
to predict all of them--data_folds
(default0
): number of folds to use during cross-validation; value of 0 indicates not to use cross-validation--data_fold
(default0
): zero-based index of a fold to use during cross-validation--data_path
(defaultbikes.tsv
): input data file intsv
format--dropout
(default0.0
): dropout rate to use--efficientnetv2_size
(defaults
): EfficientNetV2 size (s
orm
)--output
(defaultmodel
): path where the trained model should be saved--schedule
(defaultfrozen:30:1e-3,finetune:30:1e-4
): training schedule to use--seed
(default42
): random seed to use--threads
(default4
): CPU threads to use (for augmentation and other CPU computation); 0 indicates all physical cores
The script has been developed using
tensorflow==2.8.0
,tensorflow-addons==0.16.1
, andtensorflow-hub==0.12.0
, but newer (consistent) versions are expected to work too. -
predict.py
: predict the classes for the given images. The first argument is the directory with the model, all remaining arguments are paths to the filed to predict. Furthermore, the following options are supported:--batch_size
(default8
): the batch size to use during prediction--threads
(default4
): CPU threads to use; 0 indicates all physical cores
The output is a
tsv
file, the first columnimage_path
is the path to the file being predicted, and other columns are the predicted classes.Only the
tensorflow
package is required for prediction. -
predict_jackknife.py
: when a model (given as the first argument) was trained via cross-validation, perform the prediction on the development fold (the one not used during training). Output atsv
file with both gold and predicted classes for each file in the development fold. -
visualize.py
: an internal script used to visualize the cross-validation results. The input (given as the first argument) is atsv
file where columns from the third are expected to be pairs of gold and predicted values.