Skip to content
320 changes: 230 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flowvision
The flowvision package consists of popular datasets, model architectures, and common image transformations for computer vision.
The flowvision package consists of popular datasets, SOTA computer vision models, layers, utilities, schedulers, advanced data augmentations and common image transformations based on OneFlow.


## Installation
Expand All @@ -10,98 +10,214 @@ Then install the latest stable release of `flowvision`
pip install flowvision==0.0.56
```

## Overview of flowvision structure
<table align="center">
<tbody>
<tr align="center" valign="bottom">
<td>
<b>Vision Models</b>
</td>
<td>
<b>Components</b>
</td>
<td>
<b>Augmentation and Dataset</b>
</td>
</tr>
<tr valign="top">
<td>
<ul>
<li><b>Classification</b></li>
<ul>
<li>AlexNet</li>
<li>SqueezeNet</li>
<li>VGG</li>
<li>GoogleNet</li>
<li>InceptionV3</li>
<li>ResNet</li>
<li>ResNeXt</li>
<li>DenseNet</li>
<li>ShuffleNetV2</li>
<li>MobileNetV2</li>
<li>MobileNetV3</li>
<li>MNASNet</li>
<li>Res2Net</li>
<li>EfficientNet</li>
<li>GhostNet</li>
<li>ReXNet</li>
<li>Vision Transformer</li>
<li>DeiT</li>
<li>PVT</li>
<li>Swin Transformer</li>
<li>CSwin Transformer</li>
<li>CrossFormer</li>
<li>Mlp Mixer</li>
<li>ResMLP</li>
<li>gMLP</li>
<li>ConvMixer</li>
</ul>
<li><b>Detection</b></li>
<ul>
<li>SSD</li>
<li>SSDLite</li>
<li>Faster RCNN</li>
<li>RetinaNet</li>
</ul>
<li><b>Segmentation</b></li>
<ul>
<li>FCN</li>
<li>DeepLabV3</li>
</ul>
<li><b>Neural Style Transfer</b></li>
<ul>
<li>StyleNet</li>
</ul>
</ul>
</td>
<td>
<ul><li><b>Attention Layer</b></li>
<ul>
<li>SE</li>
<li>BAM</li>
<li>CBAM</li>
<li>ECA</li>
<li>Non Local Attention</li>
<li>Global Context</li>
<li>Gated Channel Transform</li>
<li>Coordinate Attention</li>
</ul>
</ul>
<ul><li><b>Regularization Layer</b></li>
<ul>
<li>Drop Block</li>
<li>Drop Path</li>
<li>Stochastic Depth</li>
<li>LayerNorm2D</li>
</ul>
</ul>
<ul><li><b>Basic Layer</b></li>
<ul>
<li>Patch Embedding</li>
<li>Mlp Block</li>
<li>FPN</li>
</ul>
</ul>
<ul><li><b>Activation Layer</b></li>
<ul>
<li>Hard Sigmoid</li>
<li>Hard Swish</li>
</ul>
</ul>
<ul><li><b>Initialization Function</b></li>
<ul>
<li>Truncated Normal</li>
<li>Lecun Normal</li>
</ul>
</ul>
<ul><li><b>LR Scheduler</b></li>
<ul>
<li>StepLRScheduler</li>
<li>MultiStepLRScheduler</li>
<li>CosineLRScheduler</li>
<li>LinearLRScheduler</li>
<li>PolyLRScheduler</li>
<li>TanhLRScheduler</li>
</ul>
</ul>
<ul><li><b>Loss</b></li>
<ul>
<li>LabelSmoothingCrossEntropy</li>
<li>SoftTargetCrossEntropy</li>
</ul>
</ul>
</td>
<td>
<ul><li><b>Basic Augmentation</b></li>
<ul>
<li>CenterCrop</li>
<li>RandomCrop</li>
<li>RandomResizedCrop</li>
<li>FiveCrop</li>
<li>TenCrop</li>
<li>RandomVerticalFlip</li>
<li>RandomHorizontalFlip</li>
<li>Resize</li>
</ul>
</ul>
<ul><li><b>Advanced Augmentation</b></li>
<ul>
<li>Mixup</li>
<li>CutMix</li>
<li>AugMix</li>
<li>RandomErasing</li>
<li>Rand Augmentation</li>
<li>Auto Augmentation</li>
</ul>
</ul>
<ul><li><b>Dataset</b></li>
<ul>
<li>CIFAR10</li>
<li>CIFAR100</li>
<li>COCO</li>
<li>FashionMNIST</li>
<li>ImageNet</li>
<li>VOC</li>
</ul>
</ul>
</td>
</tr>


</td>
</tr>
</tbody>
</table>


## Documentation
You can find the API documentation on the website: https://flowvision.readthedocs.io/en/latest/index.html

## Model Zoo
All of the supported models can be found in our model summary page [here](MODEL_SUMMARY.md).

We have conducted all the tests under the same setting, please refer to the model page [here](MODEL_ZOO.md) for more details.

## Quick Start
<details>
<summary> <b> Quick Start </b> </summary>
### Create a model
In flowvision we support two ways to create a model.

- list supported model
```python
from flowvision.models import ModelCreator
supported_model_table = ModelCreator.model_table()
print(supported_model_table)
```
- First, import the target model from `flowvision.models`, e.g., create `alexnet` from flowvision

- search supported model by wildcard
```python
from flowvision.models import ModelCreator
pretrained_vit_model = ModelCreator.model_table("*vit*", pretrained=True)
supported_vit_model = ModelCreator.model_table("*vit*", pretrained=False)
supported_alexnet_model = ModelCreator.model_table('alexnet')

# check the model table
print(pretrained_vit_model)
print(supported_vit_model)
print(supported_alexnet_model)
from flowvision.models.alexnet import alexnet
model = alexnet()
```

- create model use `ModelCreator`
- Second, create model in an easier way by using `ModelCreator`, e.g., create `alexnet` model by `ModelCreator`
```python
from flowvision.models import ModelCreator
model = ModelCreator.create_model('alexnet', pretrained=True)
alexnet = ModelCreator.create_model("alexnet")
```

</details>

<details>
<summary> <b> ModelCreator </b> </summary>

- Create model in a simple way
- To create a pretrained model, simply pass `pretrained=True` into `ModelCreator.create_model` function
```python
from flowvision.models import ModelCreator
model = ModelCreator.create_model('alexnet', pretrained=True)
alexnet = ModelCreator.create_model("alexnet", pretrained=True)
```
the pretrained weight will be saved to `./checkpoints`

- Supported model table
- To create a custom model to fit different number of classes, simply pass `num_classes=<number of class>` into `ModelCreator.create_model` function
```python
from flowvision.models import ModelCreator
supported_model_table = ModelCreator.model_table()
print(supported_model_table)
```
model = ModelCreator.create_model("alexnet", num_classes=100)
```
╒════════════════════════════════════════════╤══════════════╕
│ Supported Models │ Pretrained │
╞════════════════════════════════════════════╪══════════════╡
│ alexnet │ true │
├────────────────────────────────────────────┼──────────────┤
│ convmixer_1024_20 │ true │
├────────────────────────────────────────────┼──────────────┤
│ convmixer_1536_20 │ true │
├────────────────────────────────────────────┼──────────────┤
│ convmixer_768_32_relu │ true │
├────────────────────────────────────────────┼──────────────┤
│ shufflenet_v2_x0_5 │ true │
├────────────────────────────────────────────┼──────────────┤
│ shufflenet_v2_x1_0 │ true │
├────────────────────────────────────────────┼──────────────┤
│ shufflenet_v2_x1_5 │ false │
├────────────────────────────────────────────┼──────────────┤
│ shufflenet_v2_x2_0 │ false │
├────────────────────────────────────────────┼──────────────┤
│ ... │ ... │
├────────────────────────────────────────────┼──────────────┤
│ wide_resnet101_2 │ true │
├────────────────────────────────────────────┼──────────────┤
│ wide_resnet50_2 │ true │
╘════════════════════════════════════════════╧══════════════╛
```
show all of the supported model in the table manner

- Check the table of the models with pretrained weights.
### Tabulate all models with pretrained weights
`ModelCreator.model_table()` returns a tabular results of available models in `flowvision`. To check all of pretrained models, pass in `pretrained=True` in `ModelCreator.model_table()`.
```python
from flowvision.models import ModelCreator
pretrained_model_table = ModelCreator.model_table(pretrained=True)
print(pretrained_model_table)
```
all_pretrained_models = ModelCreator.model_table(pretrained=True)
print(all_pretrained_models)
```
You can get the results like:
```python
╒════════════════════════════════════════════╤══════════════╕
│ Supported Models │ Pretrained │
╞════════════════════════════════════════════╪══════════════╡
Expand All @@ -121,53 +237,77 @@ print(pretrained_model_table)
├────────────────────────────────────────────┼──────────────┤
│ crossformer_tiny_patch4_group7_224 │ true │
├────────────────────────────────────────────┼──────────────┤
│ ... │ ...
│ ... │ ...
├────────────────────────────────────────────┼──────────────┤
│ wide_resnet101_2 │ true │
├────────────────────────────────────────────┼──────────────┤
│ wide_resnet50_2 │ true │
╘════════════════════════════════════════════╧══════════════╛
```
- Search for model by Wildcard.

### Search for supported model by Wildcard
It is easy to search for model architectures by using Wildcard as below:
```python
from flowvision.models import ModelCreator
supported_vit_model = ModelCreator.model_table('vit*')
print(supported_vit_model)
```
all_efficientnet_models = ModelCreator.model_table("**efficientnet**")
print(all_efficientnet_models)
```
You can get the results like:
```python
╒════════════════════╤══════════════╕
│ Supported Models │ Pretrained │
╞════════════════════╪══════════════╡
vit_b_16_224 │ false
efficientnet_b0 │ true
├────────────────────┼──────────────┤
vit_b_16_384 │ true │
efficientnet_b1 │ true │
├────────────────────┼──────────────┤
vit_b_32_224 │ false
efficientnet_b2 │ true
├────────────────────┼──────────────┤
vit_b_32_384 │ true │
efficientnet_b3 │ true │
├────────────────────┼──────────────┤
vit_l_16_384 │ true │
efficientnet_b4 │ true │
├────────────────────┼──────────────┤
│ vit_l_32_384 │ true │
│ efficientnet_b5 │ true │
├────────────────────┼──────────────┤
│ efficientnet_b6 │ true │
├────────────────────┼──────────────┤
│ efficientnet_b7 │ true │
╘════════════════════╧══════════════╛
```
- Search for model with pretrained weights by Wildcard.

### List all models supported in flowvision
`ModelCreator.model_list` has similar function as `ModelCreator.model_table` but return a list object, which gives the user a more flexible way to check the supported model in flowvision.
- List all models with pretrained weights
```python
from flowvision.models import ModelCreator
ModelCreator.model_table('vit*', pretrained=True)
all_pretrained_models = ModelCreator.model_list(pretrained=True)
print(all_pretrained_models[:5])
```
You can get the results like:
```python
['alexnet',
'convmixer_1024_20',
'convmixer_1536_20',
'convmixer_768_32_relu',
'crossformer_base_patch4_group7_224']
```
╒════════════════════╤══════════════╕
│ Supported Models │ Pretrained │
╞════════════════════╪══════════════╡
│ vit_b_16_384 │ true │
├────────────────────┼──────────────┤
│ vit_b_32_384 │ true │
├────────────────────┼──────────────┤
│ vit_l_16_384 │ true │
├────────────────────┼──────────────┤
│ vit_l_32_384 │ true │
╘════════════════════╧══════════════╛

- Support wildcard search
```python
from flowvision.models import ModelCreator
all_efficientnet_models = ModelCreator.model_list("**efficientnet**")
print(all_efficientnet_models)
```
You can get the results like:
```python
['efficientnet_b0',
'efficientnet_b1',
'efficientnet_b2',
'efficientnet_b3',
'efficientnet_b4',
'efficientnet_b5',
'efficientnet_b6',
'efficientnet_b7']
```

</details>
Expand Down
Loading