Spaces:
Configuration error
Configuration error
Upload folder using huggingface_hub
Browse files- README.md +36 -86
- eval.yaml +33 -0
- finetuning.yaml +36 -0
README.md
CHANGED
@@ -1,98 +1,48 @@
|
|
1 |
-
|
2 |
-
Started guide, and browse the API material from our published documentation site
|
3 |
-
https://intelai.github.io/transfer-learning.*
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
a large dataset to improve the performance of a related problem with a smaller
|
11 |
-
dataset.
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
create transfer learning workflows across a variety of AI use cases. Its
|
17 |
-
open-source Python\* library leverages public pretrained model hubs,
|
18 |
-
Intel-optimized deep learning frameworks, and your custom dataset to efficiently
|
19 |
-
generate new models optimized for Intel hardware.
|
20 |
|
21 |
-
|
22 |
-
Transfer Learning Tool as well as Jupyter\* notebooks and examples that
|
23 |
-
demonstrate its usage.
|
24 |
|
25 |
-
**
|
26 |
-
*
|
27 |
-
*
|
28 |
-
|
29 |
-
*
|
30 |
-
* Automatically create a trainable classification layer customized for your dataset
|
31 |
-
* Pre-process your dataset using scaling, cropping, batching, and splitting
|
32 |
-
* Use APIs for prediction, evaluation, and benchmarking
|
33 |
-
* Export your model for deployment or resume training from checkpoints
|
34 |
|
35 |
-
**
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
|
50 |
-
[public datasets](DATASETS.md) documentation. Construct your own CLI or API commands for training, evaluation,
|
51 |
-
and optimization using the TensorFlow or PyTorch framework, and finally export
|
52 |
-
your saved model optimized for inference on Intel CPUs.
|
53 |
|
54 |
-
An overview of the Intel Transfer Learning Tool flow is shown in this
|
55 |
-
figure:
|
56 |
-
|
57 |
-
<p align="center"><b>Intel Transfer Learning Tool Flow</b></p>
|
58 |
-
|
59 |
-
<img alt="Intel Transfer Learning Tool Flow" title="Intel Transfer Learing Tool Flow" src="images/TLT-tool_flow.svg" width="600">
|
60 |
-
|
61 |
-
## Get Started
|
62 |
-
|
63 |
-
The [Get Started](GetStarted.md) guide walks you through the steps to check
|
64 |
-
system requirements, install, and then run the tool with a couple of examples
|
65 |
-
showing no-code CLI and low-code API approaches. After that, you can check out
|
66 |
-
these additional CLI and API [Examples](examples/README.md).
|
67 |
-
|
68 |
-
<!-- ExpandGetStarted-Start -->
|
69 |
-
As described in the [Get Started](GetStarted.md) guide, once you have a Python
|
70 |
-
3.9 environment set up, you do a basic install of the Intel Transfer Learning
|
71 |
-
Tool using:
|
72 |
-
|
73 |
-
```
|
74 |
-
pip install intel-transfer-learning-tool
|
75 |
-
```
|
76 |
-
|
77 |
-
Then you can use the Transfer Learning Tool CLI interface (tlt) to train a
|
78 |
-
TensorFlow image classification model (resnet_v1_50), download and use an
|
79 |
-
existing built-in dataset (tf_flowers), and save the trained model to
|
80 |
-
`/tmp/output` using this one command:
|
81 |
-
|
82 |
-
```
|
83 |
-
tlt train --framework tensorflow --model-name resnet_v1_50 --dataset-name tf_flowers \
|
84 |
-
--output-dir /tmp/output --dataset-dir /tmp/data
|
85 |
-
```
|
86 |
-
|
87 |
-
Use `tlt --help` to see the list of CLI commands. More detailed help for each
|
88 |
-
command can be found using, for example, `tlt train --help`.
|
89 |
-
|
90 |
-
<!-- ExpandGetStarted-End -->
|
91 |
-
|
92 |
-
## Support
|
93 |
-
|
94 |
-
The Intel Transfer Learning Tool team tracks bugs and enhancement requests using
|
95 |
-
[GitHub issues](https://github.com/IntelAI/transfer-learning-tool/issues). Before submitting a
|
96 |
-
suggestion or bug report, search the existing GitHub issues to see if your issue has already been reported.
|
97 |
-
|
98 |
-
See [Legal Information](Legal.md) for Disclaimers, Trademark, and Licensing information.
|
|
|
1 |
+
# Setting parameters and configurations
|
|
|
|
|
2 |
|
3 |
+
Please set the following in the finetuning.yaml file:
|
4 |
|
5 |
+
* **num_workers:** number of sub-processes or threads to use for data loading. Setting the argument num_workers as a positive integer will turn on multi-process data loading. (Default=32)
|
6 |
|
7 |
+
* **precision:** precision of data type in which model to be fine-tuned. Choices are [float32, bfloat16]
|
|
|
|
|
8 |
|
9 |
+
* **fine_tune:** set 'True' to run SimSiam or CutPaste self-supervised learning using Intel Transfer Learning Tool APIs. Set 'False' to run a pre-trained backbone by providing a model path under 'model_path' category
|
10 |
|
11 |
+
* **output_path:** path to save the checkpoints or final model
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
* **tlt_wf_path:** set by default to point to the workflow in the Intel Transfer Learning Tool
|
|
|
|
|
14 |
|
15 |
+
* **dataset:**
|
16 |
+
* **root_dir:** path to the root directory of MVTEC dataset
|
17 |
+
* **category_type:** category type within MVTEC dataset, e.g.: hazelnut or all (for running all categories in MVTEC)
|
18 |
+
* **batch_size:** batch size for inference (Default=32)
|
19 |
+
* **image_size:** each image resized to this size (Default=224x224)
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
* **model:** Options to select when running with a pre-trained backbone, no fine-tuning on custom dataset
|
22 |
+
* **name:** pretrained backbone model E.g.: resnet50, resnet18
|
23 |
+
* **layer:** intermediate layer from which features will be extracted
|
24 |
+
* **pool:** pooling kernel size for average pooling
|
25 |
+
* **feature_extractor:** select the type of modelling and subsequent feature extractor. Options are:
|
26 |
+
* pretrained - No fine-tuning on custom dataset, features will be extracted from pretrained model which is set in model/name
|
27 |
+
* simsiam - SimSiam self-supervised training on custom dataset
|
28 |
+
* cutpaste - CutPaste self-supervised training on custom dataset
|
29 |
|
30 |
+
* **simsiam:** Set when 'feature_extractor' is set to simsiam. For details about simsiam method, please refer to https://arxiv.org/abs/2011.10566
|
31 |
+
* **batch_size:** batch size for fine-tuning (Default=64)
|
32 |
+
* **epochs:** number of epochs to fine-tune the model
|
33 |
+
* **optim:** optimization algorithm E.g.: sgd, adam
|
34 |
+
* **model_path:** path to save the checkpoints or final model
|
35 |
+
* **ckpt:** flag to specify whether intermediate checkpoints should be saved or not
|
36 |
|
37 |
+
* **cutpaste:** Set when 'feature_extractor' is set to cutpaste. For details about cutpaste method, please refer to https://arxiv.org/abs/2104.04015
|
38 |
+
* **cutpaste_type:** type of image augmentation for cutpaste fine-tuning, choices are ['normal', 'scar', '3way', 'union'].
|
39 |
+
* **head_layer:** number of fully-connected layers on top of average pooling layer followed by the last linear layer of backbone network
|
40 |
+
* **freeze_resnet:** number of epochs till only head layers will be trained. After this, complete network will be trained.
|
41 |
+
* **batch_size:** batch size for fine-tuning (Default=64)
|
42 |
+
* **epochs:** number of epochs to fine-tune the model
|
43 |
+
* **optim:** optimization algorithm E.g.: sgd, adam
|
44 |
+
* **model_path:** path to save the checkpoints or final model
|
45 |
+
* **ckpt:** flag to specify whether intermediate checkpoints should be saved or not
|
46 |
|
47 |
+
* **pca_thresholds:** percentage of variance ratio to be retained. Number of PCA components are selected according to it
|
|
|
|
|
|
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eval.yaml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_workers: 32
|
2 |
+
precision: float32
|
3 |
+
fine_tune: false
|
4 |
+
output_path: ./output
|
5 |
+
tlt_wf_path: ./transfer-learning/workflows/vision_anomaly_detection
|
6 |
+
dataset:
|
7 |
+
root_dir: ./data
|
8 |
+
category_type: all
|
9 |
+
batch_size: 32
|
10 |
+
image_size: 224
|
11 |
+
model:
|
12 |
+
name: resnet50
|
13 |
+
layer: layer3
|
14 |
+
pool: 2
|
15 |
+
feature_extractor: simsiam
|
16 |
+
simsiam:
|
17 |
+
batch_size: 64
|
18 |
+
epochs: 2
|
19 |
+
optim: sgd
|
20 |
+
model_path: ./output
|
21 |
+
ckpt: true
|
22 |
+
initial_ckpt: null
|
23 |
+
cutpaste:
|
24 |
+
cutpaste_type: 3way
|
25 |
+
head_layer: 2
|
26 |
+
freeze_resnet: 20
|
27 |
+
batch_size: 64
|
28 |
+
epochs: 2
|
29 |
+
optim: sgd
|
30 |
+
model_path: ./output
|
31 |
+
ckpt: true
|
32 |
+
pca:
|
33 |
+
pca_thresholds: 0.99
|
finetuning.yaml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_workers: 32 # number of parallel threads to process the data
|
2 |
+
precision: float32 # supported options are [float32, bfloat16]
|
3 |
+
fine_tune : true
|
4 |
+
output_path: ./output/ # path to save the checkpoints or final model
|
5 |
+
tlt_wf_path: ./transfer-learning/workflows/vision_anomaly_detection
|
6 |
+
dataset:
|
7 |
+
root_dir: ./data/ # full path of root directory of MVTEC dataset
|
8 |
+
category_type: hazelnut # category type within MVTEC dataset, i.e. hazelnut or all (for running all categories in MVTEC)
|
9 |
+
batch_size: 32 # inference batch size
|
10 |
+
image_size: 224 # each image resized to this size (224x224)
|
11 |
+
model:
|
12 |
+
name: resnet50 # pretrained backbone model ..choices are [resnet50, resnet18]
|
13 |
+
layer: layer3 # intermediate layer from which features will be extracted
|
14 |
+
pool: 2 # pooling kernel size for average pooling
|
15 |
+
feature_extractor: cutpaste # choices are [pretrained, cutpaste, simsiam]
|
16 |
+
#pretrained - No fine-tuning on custom dataset, features will be extracted from pretrained ResNet model
|
17 |
+
#simsiam - fine-tune resnet model on custom dataset using simsiam self-supervised technique
|
18 |
+
#cutpaste - fine-tune resnet model on custom datset using cutpaste self-supervised technique
|
19 |
+
simsiam:
|
20 |
+
batch_size: 64 # fine-tuning batch size
|
21 |
+
epochs: 2 # number of epochs to fine-tune the model
|
22 |
+
optim: 'sgd' # optimizer
|
23 |
+
model_path: './output' # path to save the checkpoints or final model
|
24 |
+
ckpt: true # flag for whether intermediate checkpoints would be saved or not
|
25 |
+
initial_ckpt:
|
26 |
+
cutpaste:
|
27 |
+
cutpaste_type: '3way' # choices are ['normal', 'scar', '3way', 'union'] for image augmentation
|
28 |
+
head_layer: 2 # number of perceptron layers appended towards the end of ResNet layers
|
29 |
+
freeze_resnet: 20 # number of epochs till resnet layers will be frozen and only head layers will be trained
|
30 |
+
batch_size: 64 # fine-tuning batch size
|
31 |
+
epochs: 1 # number of epochs to fine-tune the model
|
32 |
+
optim: 'sgd' # optimizer
|
33 |
+
model_path: './output' # path to save the checkpoints or final model
|
34 |
+
ckpt: true # flag for whether intermediate checkpoints would be saved or not
|
35 |
+
pca:
|
36 |
+
pca_thresholds: 0.99 # PCA select number of components such that it ensures to retain the variance ratio specified
|