Code Decoupling: Decouple all data loading, network model construction, model training and validation
Rich Content: Providing rich evaluation indicators and functional functions
- checkpoints: stores the weights of the trained model;
- datasets: Store datasets. And partition the dataset;
- logs: Stores training logs. Including losses and accuracy during training and validation;
- option. py: stores all the parameters required for the entire project;
- utils.py: Stores various functions. Including model saving, model loading, and loss function, etc;
- split_data. py: Divide the dataset;
- model. py: Building a neural network model;
- train.py: Train the model;
- predict. py: Evaluate the training model;
- model_transfer. py: Transfer .pth model to .onnx model.
Required:
matplotlib==3.8.3 numpy==1.26.4 Pillow==9.5.0 Pillow==10.3.0 scikit_learn==1.5.0 torch==2.2.1 torchvision==0.17.1 tqdm==4.66.2
You can install these dependencies via pip:
pip install -r requirements.txtPrepare your dataset and place it according to the following requirements:
datasets images styles.csv
If you need to conduct code validity testing first, you can use Fashion-Product-Images-Small first.
Run the following script to obtain the partitioned dataset, but you need to pay attention to modifying some paths:
python split_data.pyThen you can obtain the following data structure:
datasets images styles.csv train.csv val.csv
How many categories do you need to predict? You need to add a few category headers in model.py.
Run the following script to train your dataset and output various parameters during the training and validation processes:
python train.pyRunning the following code can evaluate the accuracy of your model. You can choose to evaluate the test dataset or individual images:
python predict.pyThis project is licensed under the Apache 2.0 license. For detailed information, please refer to the LICENSE file.
Kaggle Dataset: Fashion-Product-Images-Small
CSDN: 王乐予-CSDN博客