Skip to content
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

refine_flowvision #216

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ We have conducted all the tests under the same setting, please refer to the mode

## Quick Start
### Create a model
In flowvision we support two ways to create a model.
FlowVision supports two ways to create a model:

- Import the target model from `flowvision.models`, e.g., create `alexnet` from flowvision
- Import the target model from `flowvision.models`, e.g., create `alexnet` from FlowVision

```python
from flowvision.models.alexnet import alexnet
Expand Down Expand Up @@ -284,8 +284,8 @@ You can get the results like:
╘════════════════════════════════════════════╧══════════════╛
```

### Search for supported model by Wildcard
It is easy to search for model architectures by using Wildcard as below:
### 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
all_efficientnet_models = ModelCreator.model_table("**efficientnet**")
Expand Down Expand Up @@ -314,8 +314,8 @@ You can get the results like:
╘════════════════════╧══════════════╛
```

### 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 supported in FlowVision
`ModelCreator.model_list` has similar function as `ModelCreator.model_table` but returns 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
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

## Steps for Build Docs

Before generating the doc, you need to install flowvision by:
Before generating the doc, you need to install FlowVision by:

```bash
cd ${flow-vision-path}
Expand Down
14 changes: 7 additions & 7 deletions docs/source/tutorials/Getting Started.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Getting Started

## Installation
- To install latest stable release of flowvision:
- To install the latest stable release of FlowVision:
```bash
pip install flowvision==0.1.0
```
Expand All @@ -14,9 +14,9 @@ pip install -e .

## Usage
### Create a model
In flowvision we support two ways to create a model.
FlowVision supports two ways to create a model:

- Import the target model from `flowvision.models`, e.g., create `alexnet` from flowvision
- Import the target model from `flowvision.models`, e.g., create `alexnet` from FlowVision

```python
from flowvision.models.alexnet import alexnet
Expand Down Expand Up @@ -77,8 +77,8 @@ You can get the results like:
╘════════════════════════════════════════════╧══════════════╛
```

### Search for supported model by Wildcard
It is easy to search for model architectures by using Wildcard as below:
### Search for the supported model by wildcard
It is easy to search for model architectures by using wildcard as below:
```python
from flowvision.models import ModelCreator
all_efficientnet_models = ModelCreator.model_table("**efficientnet**")
Expand Down Expand Up @@ -107,8 +107,8 @@ You can get the results like:
╘════════════════════╧══════════════╛
```

### 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 supported in FlowVision
`ModelCreator.model_list` has a similar function as `ModelCreator.model_table` but returns 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
Expand Down
14 changes: 7 additions & 7 deletions flowvision/data/auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ def __repr__(self):

def auto_augment_transform(config_str, hparams):
"""
Create a AutoAugment transform
Creates a AutoAugment transform
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边需要Creates吗2333,我怎么感觉貌似Create就行了


:param config_str: String defining configuration of auto augmentation. Consists of multiple sections separated by
dashes ('-'). The first section defines the AutoAugment policy (one of 'v0', 'v0r', 'original', 'originalr').
The remaining sections, not order sepecific determine
The remaining sections, not order specific determine
* 'mstd' - float std deviation of magnitude noise applied

Example: 'original-mstd0.5' results in AutoAugment with original policy, magnitude_std 0.5
Expand Down Expand Up @@ -681,15 +681,15 @@ def __repr__(self):

def rand_augment_transform(config_str, hparams):
"""
Create a RandAugment transform
Creates a RandAugment transform

:param config_str: String defining configuration of random augmentation. Consists of multiple sections separated by
dashes ('-'). The first section defines the specific variant of rand augment (currently only 'rand'). The remaining
sections, not order sepecific determine
sections, not order specific determine

* 'm' - integer magnitude of rand augment
* 'n' - integer num layers (number of transform ops selected per image)
* 'w' - integer probabiliy weight index (index of a set of weights to influence choice of op)
* 'w' - integer probability weight index (index of a set of weights to influence choice of op)
* 'mstd' - float std deviation of magnitude noise applied, or uniform sampling if infinity (or > 100)
* 'mmax' - set upper bound for magnitude to something other than default of _LEVEL_DENOM (10)
* 'inc' - integer (bool), use augmentations that increase in severity with magnitude (default: 0)
Expand Down Expand Up @@ -846,11 +846,11 @@ def __repr__(self):


def augment_and_mix_transform(config_str, hparams):
""" Create AugMix OneFlow transform
""" Creates AugMix OneFlow transform

:param config_str: String defining configuration of random augmentation. Consists of multiple sections separated by
dashes ('-'). The first section defines the specific variant of rand augment (currently only 'rand'). The remaining
sections, not order sepecific determine
sections, not order specific determine

* 'm' - integer magnitude (severity) of augmentation mix (default: 3)
* 'w' - integer width of augmentation chain (default: 3)
Expand Down
6 changes: 3 additions & 3 deletions flowvision/data/mixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def one_hot(x, num_classes, on_value=1.0, off_value=0.0, device="cuda"):

def mixup_target(target, num_classes, lam=1.0, smoothing=0.0, device="cuda"):
"""
Mixup the targets with label-smoothing
Mixes up the targets with label-smoothing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边用MixUp就行了,mixup整体是作为一个名词,表示一个数据增强操作

"""
off_value = smoothing / num_classes
on_value = 1.0 - smoothing + off_value
Expand All @@ -39,7 +39,7 @@ def mixup_target(target, num_classes, lam=1.0, smoothing=0.0, device="cuda"):

def rand_bbox(img_shape, lam, margin=0.0, count=None):
""" Standard CutMix bounding-box
Generates a random square bbox based on lambda value. This impl includes
generates a random square bbox based on lambda value. This implementation includes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个开头需要大写,和上面那个不算同一行,Generates

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

收到,已修改

support for enforcing a border margin as percent of bbox dimensions.

Args:
Expand Down Expand Up @@ -90,7 +90,7 @@ def rand_bbox_minmax(img_shape, minmax, count=None):
def cutmix_bbox_and_lam(
img_shape, lam, ratio_minmax=None, correct_lam=True, count=None
):
""" Generate bbox and apply lambda correction.
""" Generates bbox and apply lambda correction.
"""
if ratio_minmax is not None:
yl, yu, xl, xu = rand_bbox_minmax(img_shape, ratio_minmax, count=count)
Expand Down
4 changes: 2 additions & 2 deletions flowvision/data/random_erasing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RandomErasing:
or single image tensor after it has been normalized by dataset mean and std.

Args:
probability: Probability that the Random Erasing operation will be performed
probability: Probability that the RandomErasing operation will be performed
min_area: Minimum percentage of erased area wrt input image area
max_area: Maximum percentage of erased area wrt input image area
min_aspect: Minimum aspect ratio of erased area
Expand All @@ -36,7 +36,7 @@ class RandomErasing:
* 'rand' - erase block is same per-channel random (normal) color
* 'pixel' - erase block is per-pixel random (normal) color

max_count: Maximum number of erasing blocks per image, area per box is scaled by count.
max_count: Maximum number of erasing blocks per image, and area per box is scaled by count.
per-image count is randomly chosen between 1 and this value
"""

Expand Down
4 changes: 2 additions & 2 deletions flowvision/layers/blocks/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def batched_nms(
"""
Performs non-maximum suppression in a batched fashion.

Each index value correspond to a category, and NMS
Each index value corresponds to a category, and NMS
will not be applied between elements of different categories.

Args:
Expand Down Expand Up @@ -151,7 +151,7 @@ def _box_inter_union(boxes1: Tensor, boxes2: Tensor) -> Tuple[Tensor, Tensor]:

def box_iou(boxes1: Tensor, boxes2: Tensor) -> Tensor:
"""
Return intersection-over-union (Jaccard index) between two sets of boxes.
Returns intersection-over-union (Jaccard index) between two sets of boxes.

Both sets of boxes are expected to be in ``(x1, y1, x2, y2)`` format with
``0 <= x1 < x2`` and ``0 <= y1 < y2``.
Expand Down
10 changes: 5 additions & 5 deletions flowvision/models/detection/faster_rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FasterRCNN(GeneralizedRCNN):
The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
image, and should be in 0-1 range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -309,15 +309,15 @@ def fasterrcnn_resnet50_fpn(
**kwargs,
):
"""
Constructs a Faster R-CNN model with a ResNet-50-FPN backbone.
Constructs the Faster R-CNN model with a ResNet-50-FPN backbone.

Reference: `"Faster R-CNN: Towards Real-Time Object Detection with
Region Proposal Networks" <https://arxiv.org/abs/1506.01497>`_.

The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
images, and should be in ``0-1`` range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -475,7 +475,7 @@ def fasterrcnn_mobilenet_v3_large_320_fpn(
**kwargs,
):
"""
Constructs a low resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone tunned for mobile use-cases.
Constructs the low resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone tunned for mobile use-cases.
It works similarly to Faster R-CNN with ResNet-50 FPN backbone. See
:func:`~flowvision.models.detection.fasterrcnn_resnet50_fpn` for more
details.
Expand Down Expand Up @@ -528,7 +528,7 @@ def fasterrcnn_mobilenet_v3_large_fpn(
**kwargs,
):
"""
Constructs a high resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone.
Constructs the high resolution Faster R-CNN model with a MobileNetV3-Large FPN backbone.
It works similarly to Faster R-CNN with ResNet-50 FPN backbone. See
:func:`~flowvision.models.detection.fasterrcnn_resnet50_fpn` for more
details.
Expand Down
4 changes: 2 additions & 2 deletions flowvision/models/detection/fcos.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class FCOS(nn.Module):
The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
image, and should be in 0-1 range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -729,7 +729,7 @@ def fcos_resnet50_fpn(
The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
image, and should be in ``0-1`` range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down
4 changes: 2 additions & 2 deletions flowvision/models/detection/mask_rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MaskRCNN(FasterRCNN):
The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
image, and should be in 0-1 range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -275,7 +275,7 @@ def maskrcnn_resnet50_fpn(
The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
image, and should be in ``0-1`` range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.
During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:

Expand Down
6 changes: 3 additions & 3 deletions flowvision/models/detection/retinanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class RetinaNet(nn.Module):
The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
image, and should be in 0-1 range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -663,14 +663,14 @@ def retinanet_resnet50_fpn(
**kwargs,
):
"""
Constructs a RetinaNet model with a ResNet-50-FPN backbone.
Constructs the RetinaNet model with a ResNet-50-FPN backbone.

Reference: `"Focal Loss for Dense Object Detection" <https://arxiv.org/abs/1708.02002>`_.

The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each
image, and should be in ``0-1`` range. Different images can have different sizes.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down
8 changes: 4 additions & 4 deletions flowvision/models/detection/ssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SSD(nn.Module):
image, and should be in 0-1 range. Different images can have different sizes but they will be resized
to a fixed size before passing it to the backbone.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down Expand Up @@ -599,15 +599,15 @@ def ssd300_vgg16(
trainable_backbone_layers: Optional[int] = None,
**kwargs: Any
):
"""Constructs an SSD model with input size 300x300 and a VGG16 backbone.
"""Constructs the SSD model with input size 300x300 and a VGG16 backbone.

Reference: `"SSD: Single Shot MultiBox Detector" <https://arxiv.org/abs/1512.02325>`_.

The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each
image, and should be in 0-1 range. Different images can have different sizes but they will be resized
image, and should be in 0-1 range. Different images can have different sizes, but they will be resized
to a fixed size before passing it to the backbone.

The behavior of the model changes depending if it is in training or evaluation mode.
The behavior of the model changes depending on if it is in training or evaluation mode.

During training, the model expects both the input tensors, as well as a targets (list of dictionary),
containing:
Expand Down
2 changes: 1 addition & 1 deletion flowvision/models/detection/ssdlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def ssdlite320_mobilenet_v3_large(
norm_layer: Optional[Callable[..., nn.Module]] = None,
**kwargs: Any
):
"""Constructs an SSDlite model with input size 320x320 and a MobileNetV3 Large backbone, as described at
"""Constructs the SSDlite model with input size 320x320 and a MobileNetV3 Large backbone, as described at
`"Searching for MobileNetV3"
<https://arxiv.org/abs/1905.02244>`_ and
`"MobileNetV2: Inverted Residuals and Linear Bottlenecks"
Expand Down
6 changes: 3 additions & 3 deletions flowvision/models/segmentation/deeplabv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _load_weights(model, arch_type, backbone, progress):
def deeplabv3_resnet50_coco(
pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs
):
"""Constructs a DeepLabV3 model with a ResNet-50 backbone.
"""Constructs the DeepLabV3 model with a ResNet-50 backbone.
Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
contains the same classes as Pascal VOC
Expand All @@ -218,7 +218,7 @@ def deeplabv3_resnet50_coco(
def deeplabv3_resnet101_coco(
pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs
):
"""Constructs a DeepLabV3 model with a ResNet-101 backbone.
"""Constructs the DeepLabV3 model with a ResNet-101 backbone.
Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
contains the same classes as Pascal VOC
Expand All @@ -243,7 +243,7 @@ def deeplabv3_resnet101_coco(
def deeplabv3_mobilenet_v3_large_coco(
pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs
):
"""Constructs a DeepLabV3 model with a MobileNetV3-Large backbone.
"""Constructs the DeepLabV3 model with a MobileNetV3-Large backbone.
Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
contains the same classes as Pascal VOC
Expand Down
4 changes: 2 additions & 2 deletions flowvision/models/segmentation/fcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _load_weights(model, arch_type, backbone, progress):
def fcn_resnet50_coco(
pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs
):
"""Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.
"""Constructs the Fully-Convolutional Network model with a ResNet-50 backbone.

Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
Expand All @@ -147,7 +147,7 @@ def fcn_resnet50_coco(
def fcn_resnet101_coco(
pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs
):
"""Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.
"""Constructs the Fully-Convolutional Network model with a ResNet-101 backbone.

Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
Expand Down
2 changes: 1 addition & 1 deletion flowvision/models/segmentation/lraspp.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _segm_lraspp_mobilenetv3(backbone_name, num_classes, pretrained_backbone=Tru
def lraspp_mobilenet_v3_large_coco(
pretrained=False, progress=True, num_classes=21, **kwargs
):
"""Constructs a Lite R-ASPP Network model with a MobileNetV3-Large backbone.
"""Constructs the Lite R-ASPP Network model with a MobileNetV3-Large backbone.
Args:
pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
contains the same classes as Pascal VOC
Expand Down
Loading