dafne-models-torch-models


Namedafne-models-torch-models JSON
Version 2.0a4 PyPI version JSON
download
home_pagehttps://github.com/dafne-imaging/dafne-models
SummaryDeep Learning models module for Dafne
upload_time2024-11-05 12:19:57
maintainerNone
docs_urlNone
authorFrancesco Santini
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dafne-models
Repository for model generators

## Important!
git-lfs is required to properly check out the model weights for the "thigh" and "leg" models.

## How to use the model trainer
The model trainer is a python script that can be used to train a model on a set of images.
It is based on the keras library and uses a tensorflow backend. The model architecture is 2D and is the 
same as the "thigh" and "leg" models, that is, a modified V-Net.

The input data is in the form of "Numpy bundle" files, which contain the image dataset with the "data" key,
the resolution under the "resolution" key, in the form of a numpy vector with 2 or 3 elements corresponding
to the voxel size in the three dimensions, and various binary masks in the form of 3D numpy arrays with the same
dimensions as the data with "mask_<roi1>", "mask_<roi2>" etc. keys (where <roi1> and <roi2> are the names of the
regions of interest, e.g. mask_tibia, mask_fibula, etc).

This numpy bundle can (and should) be saved from Dafne by selecting the "Export masks"->"Numpy bundle" option.

Once multiple such datasets are collected under the same folder, the model trainer can be used.

### Usage
The recommended usage is by using the GUI for fitting, as it allows a wider range of options.
Assuming you have cloned the dafne_models repository, install it locally together with its dependencies with

```pip install -e .[gui]```

Then, run the GUI with

```python create_model_ui.py```

or simply with

```create_model_ui```

Load the data by clicking on "Choose" next to the "Data location" field and selecting the folder containing 
the numpy bundles.
Then, select the model name and the output folder and click on "Fit model". The model will start training.
You can monitor the progress from the plots that will be displayed. On the right, one segmentation of a validation
slice is displayed at the end of every epoch. The slider on the bottom chooses which validation slice is displayed.
Next to it, a checkbox lets the user choose whether the training should be stopped when the validation loss starts
to increase. This is useful to avoid overfitting, but the user can choose to stop it manually instead.

The model will be saved in the output folder as a keras model (.hdf5 file) and as a dafne model (.model file). A .py
file is also saved to build the .model file from the .hdf5 file.

### Importing a new model into Dafne
The model can be imported into Dafne by selecting "Local" as the model location in the settings, and then choosing
"Import model" from the "File" menu. If ou don't see "Import model" under the "File" menu, double-check that the
Model location is set to "Local".

### Caveats
It is highly recommended to have a correctly configured GPU for the training. Make sure that you have tensorflow
installed for the python version that you are using, and that the GPU libraries are compatible with this tensorflow
version.

## Command line usage
A command-line model trainer is also provided. It can be used to train a model from the command line, without
the GUI. It is recommended to use the GUI instead, as it allows a wider range of options.

To train a model from the command line, run

```python create_model.py <model_name> <data folder>```

where <data_folder> is the folder containing the numpy bundles, and <model_name> is the name of the model
to be trained. The model will be saved in the current folder.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dafne-imaging/dafne-models",
    "name": "dafne-models-torch-models",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Francesco Santini",
    "author_email": "francesco.santini@unibas.ch",
    "download_url": "https://files.pythonhosted.org/packages/87/c8/8f98f9c63dd830bd1e240843f80ffc3fbe12dc864d091f56b3ec5be78719/dafne_models_torch_models-2.0a4.tar.gz",
    "platform": null,
    "description": "# dafne-models\nRepository for model generators\n\n## Important!\ngit-lfs is required to properly check out the model weights for the \"thigh\" and \"leg\" models.\n\n## How to use the model trainer\nThe model trainer is a python script that can be used to train a model on a set of images.\nIt is based on the keras library and uses a tensorflow backend. The model architecture is 2D and is the \nsame as the \"thigh\" and \"leg\" models, that is, a modified V-Net.\n\nThe input data is in the form of \"Numpy bundle\" files, which contain the image dataset with the \"data\" key,\nthe resolution under the \"resolution\" key, in the form of a numpy vector with 2 or 3 elements corresponding\nto the voxel size in the three dimensions, and various binary masks in the form of 3D numpy arrays with the same\ndimensions as the data with \"mask_<roi1>\", \"mask_<roi2>\" etc. keys (where <roi1> and <roi2> are the names of the\nregions of interest, e.g. mask_tibia, mask_fibula, etc).\n\nThis numpy bundle can (and should) be saved from Dafne by selecting the \"Export masks\"->\"Numpy bundle\" option.\n\nOnce multiple such datasets are collected under the same folder, the model trainer can be used.\n\n### Usage\nThe recommended usage is by using the GUI for fitting, as it allows a wider range of options.\nAssuming you have cloned the dafne_models repository, install it locally together with its dependencies with\n\n```pip install -e .[gui]```\n\nThen, run the GUI with\n\n```python create_model_ui.py```\n\nor simply with\n\n```create_model_ui```\n\nLoad the data by clicking on \"Choose\" next to the \"Data location\" field and selecting the folder containing \nthe numpy bundles.\nThen, select the model name and the output folder and click on \"Fit model\". The model will start training.\nYou can monitor the progress from the plots that will be displayed. On the right, one segmentation of a validation\nslice is displayed at the end of every epoch. The slider on the bottom chooses which validation slice is displayed.\nNext to it, a checkbox lets the user choose whether the training should be stopped when the validation loss starts\nto increase. This is useful to avoid overfitting, but the user can choose to stop it manually instead.\n\nThe model will be saved in the output folder as a keras model (.hdf5 file) and as a dafne model (.model file). A .py\nfile is also saved to build the .model file from the .hdf5 file.\n\n### Importing a new model into Dafne\nThe model can be imported into Dafne by selecting \"Local\" as the model location in the settings, and then choosing\n\"Import model\" from the \"File\" menu. If ou don't see \"Import model\" under the \"File\" menu, double-check that the\nModel location is set to \"Local\".\n\n### Caveats\nIt is highly recommended to have a correctly configured GPU for the training. Make sure that you have tensorflow\ninstalled for the python version that you are using, and that the GPU libraries are compatible with this tensorflow\nversion.\n\n## Command line usage\nA command-line model trainer is also provided. It can be used to train a model from the command line, without\nthe GUI. It is recommended to use the GUI instead, as it allows a wider range of options.\n\nTo train a model from the command line, run\n\n```python create_model.py <model_name> <data folder>```\n\nwhere <data_folder> is the folder containing the numpy bundles, and <model_name> is the name of the model\nto be trained. The model will be saved in the current folder.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Deep Learning models module for Dafne",
    "version": "2.0a4",
    "project_urls": {
        "Bug Tracker": "https://github.com/dafne-imaging/dafne-model/issues",
        "Homepage": "https://github.com/dafne-imaging/dafne-models"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d587a25744e1f5c120173766dc7368ac21b3af63824782090d07fe10ba5bb6e4",
                "md5": "58757aeee0554b465bc879a6038ef210",
                "sha256": "c95f774d5c375780631954f7ef400c26c459e1a8d6b9db34104957361e2e5e63"
            },
            "downloads": -1,
            "filename": "dafne_models_torch_models-2.0a4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "58757aeee0554b465bc879a6038ef210",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 36192,
            "upload_time": "2024-11-05T12:19:55",
            "upload_time_iso_8601": "2024-11-05T12:19:55.786995Z",
            "url": "https://files.pythonhosted.org/packages/d5/87/a25744e1f5c120173766dc7368ac21b3af63824782090d07fe10ba5bb6e4/dafne_models_torch_models-2.0a4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87c88f98f9c63dd830bd1e240843f80ffc3fbe12dc864d091f56b3ec5be78719",
                "md5": "20c3d5ded957dc2a46a10289ef569a07",
                "sha256": "91b48c8805825872dd7fe42ac8e98d57f214fa878410886c117a5115630c5b91"
            },
            "downloads": -1,
            "filename": "dafne_models_torch_models-2.0a4.tar.gz",
            "has_sig": false,
            "md5_digest": "20c3d5ded957dc2a46a10289ef569a07",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 35328,
            "upload_time": "2024-11-05T12:19:57",
            "upload_time_iso_8601": "2024-11-05T12:19:57.256022Z",
            "url": "https://files.pythonhosted.org/packages/87/c8/8f98f9c63dd830bd1e240843f80ffc3fbe12dc864d091f56b3ec5be78719/dafne_models_torch_models-2.0a4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 12:19:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dafne-imaging",
    "github_project": "dafne-models",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "dafne-models-torch-models"
}
        
Elapsed time: 1.58071s