litten


Namelitten JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryA python package to visualize sequentail tensorflow model archtictures
upload_time2022-12-23 13:57:28
maintainer
docs_urlNone
authorHossam Asaad
requires_python>=3.6
license
keywords python tensorflow keras pil pillow visualize models visualize
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
[![Latest Version](https://img.shields.io/pypi/v/litten.svg)](https://pypi.org/project/litten/) ![GitHub repo size](https://img.shields.io/github/repo-size/hossamasaad/litten) ![GitHub contributors](https://img.shields.io/github/contributors/hossamasaad/litten) ![GitHub stars](https://img.shields.io/github/stars/hossamasaad/litten?style=social) ![GitHub forks](https://img.shields.io/github/forks/hossamasaad/litten?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/hossamasaad10?style=social)

<img src="images/bg.png" width="1000">

# Litten
Litten is a python package to visualize sequential Tensorflow(keras) neural network model architectures, Get layers summary in details, visualize conv layers filters and featurmaps. 

## Installation
To install latest version from PyPi
```bash
$ pip install litten
```

## How to use it?

1. Create your neural network archtictures

```python
model = keras.models.Sequential(
    [
        keras.layers.Conv2D(filters = 32, kernel_size = 3, input_shape = [150, 150, 3]),
        ...
        keras.layers.Dense(units = 2, activation = 'softmax')
    ]
)

# or using functional API

input = keras.Input(shape=(28, 28, 1), name="img")
...
output = keras.layers.Dense(units = 2, activation = 'softmax')(x)
model = keras.Model(input, output, name="Model")
```

2. Import LayersSummary, ModelVisualizer and create objects

```python
from litten import LayersSummary, ModelVisualizer
```

3. To get Layers Summaries
```python
summary = LayersSummary()
summary.show_layers_summaries(model)
```
Output:
```plaintext
=================================================================================================================
Layer 1: InputLayer     | Attributes
----------------------------------------
built                   :  True
sparse                  :  False
ragged                  :  False
batch_size              :  None
is_placeholder          :  True
=================================================================================================================
Layer 2: Conv2D         | Attributes
----------------------------------------
rank                    :  2
filters                 :  16
groups                  :  1
kernel_size             :  (3, 3)
strides                 :  (1, 1)
padding                 :  valid
data_format             :  channels_last
dilation_rate           :  (1, 1)
activation              :  <function relu at 0x7f6b7038fee0>
use_bias                :  True
kernel_initializer      :  <keras.initializers.initializers_v2.GlorotUniform object at 0x7f6aee189610>
bias_initializer        :  <keras.initializers.initializers_v2.Zeros object at 0x7f6aee189af0>
kernel_regularizer      :  None
bias_regularizer        :  None
kernel_constraint       :  None
bias_constraint         :  None
built                   :  True
=================================================================================================================
....
```

4. To visualize model architecture
    ```Plaintext
    ModelVisualizer.visualize_model(
        show_names=False,
        show_properties=False,
        show_connectors=False,
        pallete='default'
    )
    ```
    Example 1
    ```python
    vis = ModelVisualizer(model)
    vis.visualize_model()
    ```
    <img src="images/basic.png" width="1000">
    
        
    Example 2
    ```python
    vis.visualize_model(show_names=True)
    ```
    <img src="images/names.png" width="1000">

    Example 3
    ```python
    vis.visualize_model(show_names=True, show_connectors = True)
    ```
    <img src="images/connectors.png" width="1000">

    Exampel 4
    ```python
    vis.visualize_model(show_names=True, show_connectors = True, show_properties=True)
    ```
    <img src="images/properties.png" width="1000" height="">

    Example 5
    You can choose one from these palettes `default`, `red`, `green`, `blue`, `yellow`, `brown`, `purple`, `gray`
    ```python
    vis.visualize_model(show_names=True, show_connectors=True, palette=<palette>)
    ```
    <img src="images/gray.png"   width="600" align="center">
    <img src="images/blue.png"   width="600" align="center">
    <img src="images/red.png"    width="600" align="center">
    <img src="images/brown.png"  width="600" align="center">
    <img src="images/purple.png" width="600" align="center">


5. To visualize Conv filters
    ```plaintext
        ModelVisualizer.visualize_filters(
            cmap = 'gray'   # matplotlib cmaps
        )
    ```
    Example
    ```python
    vis = ModelVisualizer(model)
    vis.visualize_filters('Blues')
    ```
    <img src="images/filters.png" width="500">

6. To visualize Features map
    ```plaintext
    ModelVisualizer.visualize_featuremap(
        input_image,
        cmap = 'gray'   # matplotlib cmaps
    )
    ```
    Example
    ```python
    vis = ModelVisualizer(model)
    vis.visualize_featuremap(input_image, 'Blues')
    ```
    <img src="images/feature_map1.png" width="500">
    <img src="images/feature_map2.png" width="1000">
    <img src="images/feature_map3.png" width="1000">
    <img src="images/feature_map4.png" width="1000">


## Contributing to `litten`

To contribute to litten, follow these steps:

1. Fork this repository.
2. Create a branch: `git checkout -b <branch_name>`.
3. Make your changes and commit them: `git commit -m '<commit_message>'`
4. Push to the original branch: `git push origin <project_name>/<location>`
5. Create the pull request.

Alternatively see the GitHub documentation on [creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).

## License
Open source licensed under the MIT license (see _LICENSE_ file for details).

## Tools
- Python
- PIL
- Matplotlib
- pytest


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "litten",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,tensorflow,keras,PIL,pillow,visualize models,visualize",
    "author": "Hossam Asaad",
    "author_email": "hossamasaad10@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ee/52/f747eb5c982120bb1630a22e7dada4ec720ca38f61abb62f5931a168b177/litten-0.1.0.tar.gz",
    "platform": null,
    "description": "\n[![Latest Version](https://img.shields.io/pypi/v/litten.svg)](https://pypi.org/project/litten/) ![GitHub repo size](https://img.shields.io/github/repo-size/hossamasaad/litten) ![GitHub contributors](https://img.shields.io/github/contributors/hossamasaad/litten) ![GitHub stars](https://img.shields.io/github/stars/hossamasaad/litten?style=social) ![GitHub forks](https://img.shields.io/github/forks/hossamasaad/litten?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/hossamasaad10?style=social)\n\n<img src=\"images/bg.png\" width=\"1000\">\n\n# Litten\nLitten is a python package to visualize sequential Tensorflow(keras) neural network model architectures, Get layers summary in details, visualize conv layers filters and featurmaps. \n\n## Installation\nTo install latest version from PyPi\n```bash\n$ pip install litten\n```\n\n## How to use it?\n\n1. Create your neural network archtictures\n\n```python\nmodel = keras.models.Sequential(\n    [\n        keras.layers.Conv2D(filters = 32, kernel_size = 3, input_shape = [150, 150, 3]),\n        ...\n        keras.layers.Dense(units = 2, activation = 'softmax')\n    ]\n)\n\n# or using functional API\n\ninput = keras.Input(shape=(28, 28, 1), name=\"img\")\n...\noutput = keras.layers.Dense(units = 2, activation = 'softmax')(x)\nmodel = keras.Model(input, output, name=\"Model\")\n```\n\n2. Import LayersSummary, ModelVisualizer and create objects\n\n```python\nfrom litten import LayersSummary, ModelVisualizer\n```\n\n3. To get Layers Summaries\n```python\nsummary = LayersSummary()\nsummary.show_layers_summaries(model)\n```\nOutput:\n```plaintext\n=================================================================================================================\nLayer 1: InputLayer     | Attributes\n----------------------------------------\nbuilt                   :  True\nsparse                  :  False\nragged                  :  False\nbatch_size              :  None\nis_placeholder          :  True\n=================================================================================================================\nLayer 2: Conv2D         | Attributes\n----------------------------------------\nrank                    :  2\nfilters                 :  16\ngroups                  :  1\nkernel_size             :  (3, 3)\nstrides                 :  (1, 1)\npadding                 :  valid\ndata_format             :  channels_last\ndilation_rate           :  (1, 1)\nactivation              :  <function relu at 0x7f6b7038fee0>\nuse_bias                :  True\nkernel_initializer      :  <keras.initializers.initializers_v2.GlorotUniform object at 0x7f6aee189610>\nbias_initializer        :  <keras.initializers.initializers_v2.Zeros object at 0x7f6aee189af0>\nkernel_regularizer      :  None\nbias_regularizer        :  None\nkernel_constraint       :  None\nbias_constraint         :  None\nbuilt                   :  True\n=================================================================================================================\n....\n```\n\n4. To visualize model architecture\n    ```Plaintext\n    ModelVisualizer.visualize_model(\n        show_names=False,\n        show_properties=False,\n        show_connectors=False,\n        pallete='default'\n    )\n    ```\n    Example 1\n    ```python\n    vis = ModelVisualizer(model)\n    vis.visualize_model()\n    ```\n    <img src=\"images/basic.png\" width=\"1000\">\n    \n        \n    Example 2\n    ```python\n    vis.visualize_model(show_names=True)\n    ```\n    <img src=\"images/names.png\" width=\"1000\">\n\n    Example 3\n    ```python\n    vis.visualize_model(show_names=True, show_connectors = True)\n    ```\n    <img src=\"images/connectors.png\" width=\"1000\">\n\n    Exampel 4\n    ```python\n    vis.visualize_model(show_names=True, show_connectors = True, show_properties=True)\n    ```\n    <img src=\"images/properties.png\" width=\"1000\" height=\"\">\n\n    Example 5\n    You can choose one from these palettes `default`, `red`, `green`, `blue`, `yellow`, `brown`, `purple`, `gray`\n    ```python\n    vis.visualize_model(show_names=True, show_connectors=True, palette=<palette>)\n    ```\n    <img src=\"images/gray.png\"   width=\"600\" align=\"center\">\n    <img src=\"images/blue.png\"   width=\"600\" align=\"center\">\n    <img src=\"images/red.png\"    width=\"600\" align=\"center\">\n    <img src=\"images/brown.png\"  width=\"600\" align=\"center\">\n    <img src=\"images/purple.png\" width=\"600\" align=\"center\">\n\n\n5. To visualize Conv filters\n    ```plaintext\n        ModelVisualizer.visualize_filters(\n            cmap = 'gray'   # matplotlib cmaps\n        )\n    ```\n    Example\n    ```python\n    vis = ModelVisualizer(model)\n    vis.visualize_filters('Blues')\n    ```\n    <img src=\"images/filters.png\" width=\"500\">\n\n6. To visualize Features map\n    ```plaintext\n    ModelVisualizer.visualize_featuremap(\n        input_image,\n        cmap = 'gray'   # matplotlib cmaps\n    )\n    ```\n    Example\n    ```python\n    vis = ModelVisualizer(model)\n    vis.visualize_featuremap(input_image, 'Blues')\n    ```\n    <img src=\"images/feature_map1.png\" width=\"500\">\n    <img src=\"images/feature_map2.png\" width=\"1000\">\n    <img src=\"images/feature_map3.png\" width=\"1000\">\n    <img src=\"images/feature_map4.png\" width=\"1000\">\n\n\n## Contributing to `litten`\n\nTo contribute to litten, follow these steps:\n\n1. Fork this repository.\n2. Create a branch: `git checkout -b <branch_name>`.\n3. Make your changes and commit them: `git commit -m '<commit_message>'`\n4. Push to the original branch: `git push origin <project_name>/<location>`\n5. Create the pull request.\n\nAlternatively see the GitHub documentation on [creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).\n\n## License\nOpen source licensed under the MIT license (see _LICENSE_ file for details).\n\n## Tools\n- Python\n- PIL\n- Matplotlib\n- pytest\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A python package to visualize sequentail tensorflow model archtictures",
    "version": "0.1.0",
    "split_keywords": [
        "python",
        "tensorflow",
        "keras",
        "pil",
        "pillow",
        "visualize models",
        "visualize"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "32007b1a7a4d757e570459de4ff64332",
                "sha256": "aaffd13a7444d4df44b52317f018e7d6bb397b1f8ce0b0c26cd515dc3c0f59d3"
            },
            "downloads": -1,
            "filename": "litten-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "32007b1a7a4d757e570459de4ff64332",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 12042,
            "upload_time": "2022-12-23T13:57:26",
            "upload_time_iso_8601": "2022-12-23T13:57:26.907459Z",
            "url": "https://files.pythonhosted.org/packages/f5/59/ef367da99633b72c060911ae78ba3c3156f583b5af005209b0b2dd269b8b/litten-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "de1e75cf9439aeab7ca58bcbda643f32",
                "sha256": "7d3135de7c89ee9dfb901ed18cf82835b88d6fc24a0856076f21ee85be36b323"
            },
            "downloads": -1,
            "filename": "litten-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "de1e75cf9439aeab7ca58bcbda643f32",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12385,
            "upload_time": "2022-12-23T13:57:28",
            "upload_time_iso_8601": "2022-12-23T13:57:28.952888Z",
            "url": "https://files.pythonhosted.org/packages/ee/52/f747eb5c982120bb1630a22e7dada4ec720ca38f61abb62f5931a168b177/litten-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-23 13:57:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "litten"
}
        
Elapsed time: 0.05711s