Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 1 addition & 1 deletion docs/apis/data_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
|-------|----|--------|-----|
|`data_dir`|`str`|数据集存放目录。||
|`image_dir`|`str`|输入图像存放目录。||
|`ann_path`|`str`|[COCO格式](https://cocodataset.org/#home)标注文件路径。||
|`anno_path`|`str`|[COCO格式](https://cocodataset.org/#home)标注文件路径。||
|`transforms`|`paddlers.transforms.Compose`|对输入数据应用的数据变换算子。||
|`label_list`|`str` \| `None`|label list文件。label list是一个文本文件,其中每一行包含一个类别的名称。|`None`|
|`num_workers`|`int` \| `str`|加载数据时使用的辅助进程数。若设置为`'auto'`,则按照如下规则确定使用进程数:当CPU核心数大于16时,使用8个数据读取辅助进程;否则,使用CPU核心数一半数量的辅助进程。|`'auto'`|
Expand Down
2 changes: 1 addition & 1 deletion docs/apis/data_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The initialization parameter list is as follows:
|-------|----|--------|-----|
|`data_dir`|`str`|Directory that stores the dataset.||
|`image_dir`|`str`|Directory of input images.||
|`ann_path`|`str`|[COCO Format](https://cocodataset.org/#home)label file path.||
|`anno_path`|`str`|[COCO Format](https://cocodataset.org/#home)label file path.||
|`transforms`|`paddlers.transforms.Compose`|Data transformation operators applied to input data.||
|`label_list`|`str` \| `None`|Label list path. Label list is a text file, in which each line contains the name of class.|`None`|
|`num_workers`|`int` \| `str`|Number of auxiliary processes used when loading data. If it is set to `'auto'`, use the following rules to determine the number of processes to use: When the number of CPU cores is greater than 16, 8 data read auxiliary processes are used; otherwise, the number of auxiliary processes is set to half the counts of CPU cores.|`'auto'`|
Expand Down
4 changes: 4 additions & 0 deletions docs/apis/train_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def train(self,
train_dataset,
train_batch_size=64,
eval_dataset=None,
train_batch_transforms=None,
eval_batch_transforms=None,
optimizer=None,
save_interval_epochs=1,
log_interval_steps=10,
Expand Down Expand Up @@ -186,6 +188,8 @@ def train(self,
|`train_dataset`|`paddlers.datasets.COCODetDataset` \| `paddlers.datasets.VOCDetDataset` |训练数据集。||
|`train_batch_size`|`int`|训练时使用的batch size。|`64`|
|`eval_dataset`|`paddlers.datasets.COCODetDataset` \| `paddlers.datasets.VOCDetDataset` \| `None`|验证数据集。|`None`|
|`train_batch_transforms`|`paddlers.transforms.BatchCompose` \| `None`|训练集上的批数据变换算子。|`None`|
|`eval_batch_transforms`|`paddlers.transforms.BatchCompose` \| `None`|验证集上的批数据变换算子。|`None`|
|`optimizer`|`paddle.optimizer.Optimizer` \| `None`|训练时使用的优化器。若为`None`,则使用默认定义的优化器。|`None`|
|`save_interval_epochs`|`int`|训练时存储模型的间隔epoch数。|`1`|
|`log_interval_steps`|`int`|训练时打印日志的间隔step数(即迭代数)。|`10`|
Expand Down
4 changes: 4 additions & 0 deletions docs/apis/train_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def train(self,
train_dataset,
train_batch_size=2,
eval_dataset=None,
train_batch_transforms=None,
eval_batch_transforms=None,
optimizer=None,
save_interval_epochs=1,
log_interval_steps=2,
Expand All @@ -79,6 +81,8 @@ The meaning of each parameter is as follows:
|`train_dataset`|`paddlers.datasets.CDDataset`|Training dataset.||
|`train_batch_size`|`int`|Batch size used during training.|`2`|
|`eval_dataset`|`paddlers.datasets.CDDataset` \| `None`|Validation dataset.|`None`|
|`train_batch_transforms`|`paddlers.transforms.BatchCompose` \| `None`|Batch data transformation operators in train data.|`None`|
|`eval_batch_transforms`|`paddlers.transforms.BatchCompose` \| `None`|Batch data transformation operators in eval data.|`None`|
|`optimizer`|`paddle.optimizer.Optimizer` \| `None`|Optimizer used during training. If `None`, the optimizer defined by default is used.|`None`|
|`save_interval_epochs`|`int`|Number of intervals (in epochs) to evaluate and store models during training.|`1`|
|`log_interval_steps`|`int`|Number of interval steps (i.e., the number of iterations) to print logs during training.|`2`|
Expand Down
2 changes: 1 addition & 1 deletion docs/data/dataset_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PaddleRS搜集汇总了遥感领域常用的**开源**深度学习数据集,提供每个数据集的以下信息:数据集说明,影像信息,标注信息,源地址,AI Studio备份链接。这些数据集按任务类型可分为**图像分类、图像分割、变化检测、目标检测、目标跟踪、多标签分类、图像生成**等多种类型。目前已收录的遥感数据集有:

* 图像分类数据集32个;
* 目标检测数据集40个
* 目标检测数据集41个
* 图像分割数据集70个;
* 变化检测数据集28个;
* 实例分割数据集7个;
Expand Down
2 changes: 1 addition & 1 deletion docs/data/dataset_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PaddleRS has collected and summarized the most commonly used **open source** datasets in the field of remote sensing, providing the following information for each data set: dataset description, image information, annotation information, source address, and AI Studio backup link. According to the task type, these data sets can be divided into **image classification, image segmentation, change detection, object detection, object tracking, multi-label classification, image generation**, and other types. Currently, the collected remote sensing datasets include:

* 32 image classification datasets;
* 40 object detection datasets;
* 41 object detection datasets;
* 70 image segmentation datasets;
* 28 change detection datasets;
* 7 instance segmentation datasets;
Expand Down
1 change: 1 addition & 0 deletions docs/intro/data_prep_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
| 变化检测 | Season-varying | https://paperswithcode.com/dataset/cdd-dataset-season-varying | [prepare_svcd.py](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_svcd.py) |
| 场景分类 | UC Merced | http://weegee.vision.ucmerced.edu/datasets/landuse.html | [prepare_ucmerced.py](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_ucmerced.py) |
| 目标检测 | RSOD | https://github.com/RSIA-LIESMARS-WHU/RSOD-Dataset- | [prepare_rsod](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_rsod.py) |
| 旋转目标检测 | DOTA | https://captain-whu.github.io/DOTA/ | [prepare_dota](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_dota.py) |
| 图像分割 | iSAID | https://captain-whu.github.io/iSAID/ | [prepare_isaid](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_isaid.py) |
1 change: 1 addition & 0 deletions docs/intro/data_prep_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
| Change Detection | Season-varying | https://paperswithcode.com/dataset/cdd-dataset-season-varying | [prepare_svcd.py](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_svcd.py) |
| Scene Classification | UC Merced | http://weegee.vision.ucmerced.edu/datasets/landuse.html | [prepare_ucmerced.py](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_ucmerced.py) |
| Object Detection | RSOD | https://github.com/RSIA-LIESMARS-WHU/RSOD-Dataset- | [prepare_rsod](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_rsod.py) |
| Rotated Object Detection | DOTA | https://captain-whu.github.io/DOTA/ | [prepare_dota](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_dota.py) |
| Image Segmentation | iSAID | https://captain-whu.github.io/iSAID/ | [prepare_isaid](https://github.com/PaddlePaddle/PaddleRS/blob/develop/tools/prepare_dataset/prepare_isaid.py) |
1 change: 1 addition & 0 deletions docs/intro/model_cons_params_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@

| 参数名 | 描述 | 默认值 |
| --- |-------------------------------| --- |
| `rotate (bool)` | 表示是否是旋转框检测 | `False` |
| `num_classes (int)` | 目标类别数量 | `80` |
| `backbone (str)` | 骨干网络名称 | `'MobileNetV1'` |
| `anchors (list[list[int]])` | 预定义锚框的大小 | `[[10, 13], [16, 30], [33, 23], [30, 61], [62, 45], [59, 119], [116, 90], [156, 198], [373, 326]]` |
Expand Down
1 change: 1 addition & 0 deletions docs/intro/model_cons_params_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ The YOLOv3 implementation based on PaddlePaddle.

| Parameter Name | Description | Default Value |
| --- |-----------------------------------------------------------------------------------------------------------------------------| --- |
| `rotate (bool)` | If True, the model performs rotation box detection. | `False` |
| `num_classes (int)` | Number of target classes | `80` |
| `backbone (str)` | Backbone network to use | `'MobileNetV1'` |
| `anchors (list[list[int]])` | Sizes of predefined anchor boxes | `[[10, 13], [16, 30], [33, 23], [30, 61], [62, 45 ], [59, 119], [116, 90], [156, 198], [373, 326]]` |
Expand Down
1 change: 1 addition & 0 deletions docs/intro/model_zoo_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PaddleRS目前已支持的全部模型如下(标注\*的为遥感专用模型
| 目标检测 | PP-YOLO Tiny | 否 |
| 目标检测 | PP-YOLOv2 | 否 |
| 目标检测 | YOLOv3 | 否 |
| 目标检测 | FCOS-R | 否 |
| 图像分割 | BiSeNet V2 | 是 |
| 图像分割 | DeepLab V3+ | 是 |
| 图像分割 | \*FactSeg | 是 |
Expand Down
1 change: 1 addition & 0 deletions docs/intro/model_zoo_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ All models currently supported by PaddleRS are listed below (those marked \* are
| Object Detection | PP-YOLO Tiny | No |
| Object Detection | PP-YOLOv2 | No |
| Object Detection | YOLOv3 | No |
| Rotated Object Detection | FCOS-R | No |
| Image Segmentation | BiSeNet V2 | Yes |
| Image Segmentation | DeepLab V3+ | Yes |
| Image Segmentation | \*FactSeg | Yes |
Expand Down
1 change: 1 addition & 0 deletions paddlers/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, data_dir, label_list, transforms, num_workers, shuffle):

self.num_workers = get_num_workers(num_workers)
self.shuffle = shuffle
self.batch_transform = None

def __getitem__(self, idx):
sample = construct_sample_from_dict(self.file_list[idx])
Expand Down
70 changes: 44 additions & 26 deletions paddlers/datasets/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import os.path as osp
import random
from collections import OrderedDict
from collections import OrderedDict, defaultdict

import numpy as np

Expand All @@ -34,7 +34,7 @@ class COCODetDataset(BaseDataset):
Args:
data_dir (str): Root directory of the dataset.
image_dir (str): Directory that contains the images.
ann_path (str): Path to COCO annotations.
anno_path (str): Path to COCO annotations.
transforms (paddlers.transforms.Compose|list): Data preprocessing and data augmentation operators to apply.
label_list (str|None, optional): Path of the file that contains the category names. Defaults to None.
num_workers (int|str, optional): Number of processes used for data loading. If `num_workers` is 'auto',
Expand All @@ -52,7 +52,7 @@ def __init__(self,
image_dir,
anno_path,
transforms,
label_list,
label_list=None,
num_workers='auto',
shuffle=False,
allow_empty=False,
Expand Down Expand Up @@ -83,26 +83,25 @@ def __init__(self,
self.file_list = list()
neg_file_list = list()
self.labels = list()
self.anno_path = anno_path

annotations = dict()
annotations['images'] = list()
annotations['categories'] = list()
annotations['annotations'] = list()
annotations = defaultdict(list)

cname2cid = OrderedDict()
label_id = 0
with open(label_list, 'r', encoding=get_encoding(label_list)) as f:
for line in f.readlines():
cname2cid[line.strip()] = label_id
label_id += 1
self.labels.append(line.strip())

for k, v in cname2cid.items():
annotations['categories'].append({
'supercategory': 'component',
'id': v + 1,
'name': k
})
if label_list:
with open(label_list, 'r', encoding=get_encoding(label_list)) as f:
for line in f.readlines():
cname2cid[line.strip()] = label_id
label_id += 1
self.labels.append(line.strip())

for k, v in cname2cid.items():
annotations['categories'].append({
'supercategory': 'component',
'id': v + 1,
'name': k
})

anno_path = norm_path(os.path.join(self.data_dir, anno_path))
image_dir = norm_path(os.path.join(self.data_dir, image_dir))
Expand Down Expand Up @@ -155,7 +154,8 @@ def __init__(self,
gt_classes = []
gt_bboxs = []
gt_scores = []
difficults = []
gt_poly = []
difficulties = []

for inst in instances:
# Check gt bbox
Expand All @@ -182,31 +182,43 @@ def __init__(self,
'area: {} x1: {}, y1: {}, x2: {}, y2: {}.'.format(
img_id, float(inst['area']), x1, y1, x2, y2))

if 'segmentation' in inst and inst['iscrowd']:
gt_poly.append([0.0 for _ in range(8)])
elif 'segmentation' in inst and inst['segmentation']:
if not np.array(
inst['segmentation'],
dtype=object).size > 0 and not self.allow_empty:
continue
else:
gt_poly.append(inst['segmentation'])

is_crowds.append([inst['iscrowd']])
gt_classes.append([inst['category_id']])
gt_classes.append([catid2clsid[inst['category_id']]])
gt_bboxs.append(inst['clean_bbox'])
gt_scores.append([1.])
difficults.append([0])

difficulties.append(inst.get('difficult', 0.))
annotations['annotations'].append({
'iscrowd': inst['iscrowd'],
'image_id': int(inst['image_id']),
'bbox': inst['clean_bbox'],
'area': inst['area'],
'category_id': inst['category_id'],
'id': inst['id'],
'difficult': 0
'difficult': inst.get('difficult', 0.)
})
if gt_poly:
annotations['annotations'][-1]['gt_poly'] = gt_poly[-1]

label_info = {
'is_crowd': np.array(is_crowds),
'gt_class': np.array(gt_classes),
'gt_bbox': np.array(gt_bboxs).astype(np.float32),
'gt_score': np.array(gt_scores).astype(np.float32),
'difficult': np.array(difficults),
'difficult': np.array(difficulties),
'gt_poly': np.array(gt_poly),
}

if label_info['gt_bbox'].size > 0:
if label_info['gt_bbox'].size > 0 or label_info['gt_poly'].size > 0:
self.file_list.append({ ** im_info, ** label_info})
annotations['images'].append({
'height': im_h,
Expand Down Expand Up @@ -259,13 +271,19 @@ def __getitem__(self, idx):
DecodeImg(to_rgb=False)(sample),
DecodeImg(to_rgb=False)(sample_mix)
])

sample['trans_info'] = []
sample, trans_info = self.transforms(sample)
return sample, trans_info

def __len__(self):
return self.num_samples

def get_anno_path(self):
if self.anno_path:
return norm_path(os.path.join(self.data_dir, self.anno_path))
return None

def set_epoch(self, epoch_id):
self._epoch = epoch_id

Expand Down
9 changes: 9 additions & 0 deletions paddlers/models/ppdet/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ def __getattr__(self, key):
return self[key]
raise AttributeError("object has no attribute '{}'".format(key))

def __setattr__(self, key, value):
self[key] = value

def copy(self):
new_dict = AttrDict()
for k, v in self.items():
new_dict.update({k: v})
return new_dict


global_config = AttrDict()

Expand Down
Loading