-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Custom Dataset Training Support #154
Changes from 22 commits
f175a24
f841f51
12cd8ee
7bc453f
3a32443
132ceb1
907281f
16de223
c2353db
287c974
df8b655
966ad94
97d98fa
1e78a31
f6cba9a
9513723
b71f4d3
28f7d3e
83c1384
09908b0
215df46
ee12a7a
cf22594
8b827d4
2d24d16
6646c3b
b3cf100
00e8020
8e47bd3
314b164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,33 @@ where the currently available models are: | |
- [DFKDE](anomalib/models/dfkde) | ||
- [GANomaly](anomalib/models/ganomaly) | ||
|
||
### Custom Dataset | ||
It is also possible to train on a custom dataset. To do so, `data` section in `config.yaml` is to be modified as follows: | ||
```yaml | ||
dataset: | ||
name: custom | ||
path: <path/to/custom/dataset> | ||
normal: normal # name of the folder containing normal images. | ||
abnormal: abnormal # name of the folder containing abnormal images. | ||
task: segmentation # classification or segmentation | ||
mask: <path/to/mask/annotations> #optional | ||
extensions: null | ||
split_ratio: 0.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add some comments here to the parameters that may be hard to understand. e.g. |
||
seed: 0 | ||
image_size: 256 | ||
train_batch_size: 32 | ||
test_batch_size: 32 | ||
num_workers: 8 | ||
transform_config: null | ||
create_validation_set: true | ||
tiling: | ||
apply: false | ||
tile_size: null | ||
stride: null | ||
remove_border_count: 0 | ||
use_random_tiling: False | ||
random_tile_count: 16 | ||
``` | ||
## Inference | ||
|
||
Anomalib contains several tools that can be used to perform inference with a trained model. The script in [`tools/inference`](tools/inference.py) contains an example of how the inference tools can be used to generate a prediction for an input image. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,8 @@ def get_configurable_parameters( | |
config = update_input_size_config(config) | ||
|
||
# Project Configs | ||
project_path = Path(config.project.path) / config.model.name / config.dataset.name / config.dataset.category | ||
category = config.dataset.category if "category" in config.dataset.keys() else "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be a bit more clear if we check the dataset type here, and only add the category to the path if the type is MVTec. |
||
project_path = Path(config.project.path) / config.model.name / config.dataset.name / category | ||
(project_path / "weights").mkdir(parents=True, exist_ok=True) | ||
(project_path / "images").mkdir(parents=True, exist_ok=True) | ||
config.project.path = str(project_path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use
format
here instead ofname
. For MVTec we also have aformat
field in addition toname
. The way I see it,format
determines which dataset class is used under the hood, whilename
can be anything that identifies the specific dataset that is used.