How to use 10,582 trainaug images on DeeplabV3 code?

You know what I mean if you have experience on training segmentation network models on Pascal VOC dataset. The dataset only provides 1464 pixel-level image annotations for training. But every paper uses 10,582 images for training, which is usually called trainaug. The additional annotations are from SBD, but the annotation format is not the same as Pascal VOC. Fortunately someone has already made a converted version, which is SegmentationClassAug.

DeeplabV3 code do not contain SBD annotations for some reasons that we can understand. So I wrote a simple script to solve this.

To use 10,582 trainaug images on DeeplabV3 code, you just need to do the following steps:

1. Create a script named convert_voc2012_aug.sh.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Exit immediately if a command exits with a non-zero status.
set -e

CURRENT_DIR=$(pwd)
WORK_DIR="./pascal_voc_seg"
mkdir -p ${WORK_DIR}

cd ${WORK_DIR}
tar -xf "../VOCtrainval_11-May-2012.tar"
cp "../trainaug.txt" "./VOCdevkit/VOC2012/ImageSets/Segmentation"
unzip "../SegmentationClassAug.zip" -d "./VOCdevkit/VOC2012"
rm -r "./VOCdevkit/VOC2012/__MACOSX"

cd ${CURRENT_DIR}

# Root path for PASCAL VOC 2012 dataset.
PASCAL_ROOT="${WORK_DIR}/VOCdevkit/VOC2012"

# Remove the colormap in the ground truth annotations.
SEG_FOLDER="${PASCAL_ROOT}/SegmentationClassAug"
SEMANTIC_SEG_FOLDER="${PASCAL_ROOT}/SegmentationClassAugRaw"

echo "Removing the color map in ground truth annotations..."
python ./remove_gt_colormap.py \
--original_gt_folder="${SEG_FOLDER}" \
--output_dir="${SEMANTIC_SEG_FOLDER}"

# Build TFRecords of the dataset.
# First, create output directory for storing TFRecords.
OUTPUT_DIR="${WORK_DIR}/tfrecord"
mkdir -p "${OUTPUT_DIR}"

IMAGE_FOLDER="${PASCAL_ROOT}/JPEGImages"
LIST_FOLDER="${PASCAL_ROOT}/ImageSets/Segmentation"

echo "Converting PASCAL VOC 2012 dataset..."
python ./build_voc2012_data.py \
--image_folder="${IMAGE_FOLDER}" \
--semantic_segmentation_folder="${SEMANTIC_SEG_FOLDER}" \
--list_folder="${LIST_FOLDER}" \
--image_format="jpg" \
--output_dir="${OUTPUT_DIR}"

2. Create a txt file named trainaug.txt with this content.

3. Download Pascal VOC dataset and SegmentationClassAug annotations.

4. Put all of them (‘convert_voc2012_aug.sh’, ‘trainaug.txt’, ‘VOCtrainval_11-May-2012.tar’, ‘SegmentationClassAug.zip’) to the research/deeplab/datasets folder.

5. Execute convert_voc2012_aug.sh (give it execute permission) in research/deeplab/datasets.

6. Change the code in research/deeplab/datasets/segmentation_dataset.py from:

1
2
3
4
5
6
7
8
9
_PASCAL_VOC_SEG_INFORMATION = DatasetDescriptor(
splits_to_sizes={
'train': 1464,
'trainval': 2913,
'val': 1449,
},
num_classes=21,
ignore_label=255,
)

to:

1
2
3
4
5
6
7
8
9
10
_PASCAL_VOC_SEG_INFORMATION = DatasetDescriptor(
splits_to_sizes={
'train': 1464,
'trainaug': 10582,
'trainval': 2913,
'val': 1449,
},
num_classes=21,
ignore_label=255,
)

7. Don’t forget to change the train_split parameter in research/deeplab/train.py to trainaug.

SIFT算法的Matlab实现

这是一次作业,内容是给出两张图像,检测特征点和匹配特征点。要求不能用诸如OpenCV的现成特征点检测函数。于是就只能造轮子了,写了这个Matlab版的sift。(其实就是把c语言的opensift翻译成了matlab

以下是算法流程,其实网上的类似博文已经很多了,只不过我看的过程中也看得不很明白,只能对照着好几个看,所以干脆自己又写了一遍。下面的图均来自于参考资料中,然而参考资料的图也是来自于参考资料的参考资料中。

1. 构建尺度空间

定理1 对图像做 的高斯平滑,再做一次 的高斯平滑,等效于对原图像做一次 的高斯平滑。

1.1 构建高斯金字塔

高斯卷积核是实现尺度变换的唯一线性核(Koenderink, 1984; Lindeberg, 1994)。

一幅图像的尺度空间被定义为对其做可变尺度的高斯卷积:

对于给定的彩色图像,转化为灰度图像,用不同大小的做高斯平滑(按照 3 准则,高斯核矩阵的大小设为 ,并保证行和列为奇数),再此基础上将图像降采样得到不同大小的组(octave),每组若干图像(interval)。详细描述如下:

为了得到更多的特征点,将图像扩大为原来的两倍。假设原图像已有 的高斯平滑,而我们需要第一个octave的第一张图像的 ,按照定理1,我们要对扩大两倍的图像做一次高斯平滑, 。

上一个octave的图像的长度和宽度分别是下一个octave的图像的两倍。因此图像组数(octaves)可由图像大小决定,将其设为 ,这样将使顶层octave图像的长度和宽度最小值在8像素左右。

设第m个octave的第n张图像相对于原始图像的参数为 ,则。每个octave有s+1张图像(即intervals),这样得到的高斯差分金字塔(DoG)每个octave将有s张图像,我们设s为3。为了满足在不同octave间尺度的连续性,并使 ,按照定理1,则:

Parameter Sigma

Read More