Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #100 from daita-technologies/develop
Browse files Browse the repository at this point in the history
✨Release 1.1 `ai-tools`
  • Loading branch information
ttattl authored Nov 22, 2022
2 parents 36a0135 + dcd84dc commit a53f02a
Show file tree
Hide file tree
Showing 651 changed files with 26,220 additions and 204 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ignore everything
**
# Allow heathcheck module
# Allow healthcheck module
!healthcheck/**
# Allow augmentation module
!augmentation/**
Expand All @@ -10,3 +10,5 @@
!requirements*
# Allow all Dockerfile
!Dockerfile*
# Allow all python files
!*.py
35 changes: 0 additions & 35 deletions .github/workflows/lint.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ List of preprocessing methods:
- `NormalizeHue`: Adjust hue of image to match with a reference image if the difference `> 75%`.
- `NormalizeSaturation`: Adjust saturation of image to match with a reference image if the difference `> 75%`.
- `NormalizeSharpness`: Adjust sharpness of image to match with a reference image if the difference `> 75%`.
- `NormalizeContrast`: Adjust constrast of image to match with a reference image if the difference `> 75%`.
- `NormalizeContrast`: Adjust contrast of image to match with a reference image if the difference `> 75%`.
- `EqualizeHistogram`: Equalize the histogram of an image if the contrast is low.
- `IncreaseResolution`: Increase resolution of a tensor image given a reference image.

Expand All @@ -36,7 +36,7 @@ List of augmentation methods:
- `random_brightness`: Changing brightness of image randomly. Brightness factor range: `0.75` to `1.5`.
- `random_hue`: Change hue of image randomly. Hue factor range: `-0.5` to `0.5`.
- `random_saturation`: Change saturation of image randomly. Saturation factor range: `0.5` to `1.5`.
- `random_contrast`: Change constrast of image randomly. Contrast factor range: `0.5` to `1.5`.
- `random_contrast`: Change contrast of image randomly. Contrast factor range: `0.5` to `1.5`.
- `random_solarize`: Solarize an image randomly; `thresholds = 0.1`, `additions = 0.1`.
- `random_posterize`: Posterize an image randomly; `bits = 3`.
- `super_resolution`: Change resolution of an image; `scale = 2`.
Expand Down
33 changes: 33 additions & 0 deletions SegFormer/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:3.8.13-slim

# Install necessary build tools
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends git build-essential ffmpeg libsm6 libxext6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Change default directory
WORKDIR /app

# Install dependencies
COPY requirements-cpu.txt .
RUN pip install --no-cache-dir \
-r requirements-cpu.txt \
--find-links=https://download.pytorch.org/whl/torch_stable.html \
--find-links=https://download.openmmlab.com/mmcv/dist/cpu/torch1.7.0/index.html

# Set environment variable
ENV PYTHONPATH="$PYTHONPATH:/app"

# Copy model's checkpoint
COPY checkpoints/segformer.b0.1024x1024.city.160k.pth checkpoints/segformer.b0.1024x1024.city.160k.pth

# Install dependencies
COPY mmseg mmseg
COPY setup.py setup.py

# Copy necessary files to docker image
COPY local_configs local_configs
COPY run.py run.py

ENTRYPOINT ["python", "run.py"]
60 changes: 60 additions & 0 deletions SegFormer/configs/_base_/datasets/ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# dataset settings
dataset_type = "ADE20KDataset"
data_root = "data/ade/ADEChallengeData2016"
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
crop_size = (512, 512)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations", reduce_zero_label=True),
dict(type="Resize", img_scale=(2048, 512), ratio_range=(0.5, 2.0)),
dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=(2048, 512),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]
data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/training",
ann_dir="annotations/training",
pipeline=train_pipeline,
),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/validation",
ann_dir="annotations/validation",
pipeline=test_pipeline,
),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/validation",
ann_dir="annotations/validation",
pipeline=test_pipeline,
),
)
66 changes: 66 additions & 0 deletions SegFormer/configs/_base_/datasets/chase_db1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# dataset settings
dataset_type = "ChaseDB1Dataset"
data_root = "data/CHASE_DB1"
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
img_scale = (960, 999)
crop_size = (128, 128)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations"),
dict(type="Resize", img_scale=img_scale, ratio_range=(0.5, 2.0)),
dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=img_scale,
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]

data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
type="RepeatDataset",
times=40000,
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/training",
ann_dir="annotations/training",
pipeline=train_pipeline,
),
),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/validation",
ann_dir="annotations/validation",
pipeline=test_pipeline,
),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir="images/validation",
ann_dir="annotations/validation",
pipeline=test_pipeline,
),
)
60 changes: 60 additions & 0 deletions SegFormer/configs/_base_/datasets/cityscapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# dataset settings
dataset_type = "CityscapesDataset"
data_root = "data/cityscapes/"
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
crop_size = (512, 1024)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations"),
dict(type="Resize", img_scale=(2048, 1024), ratio_range=(0.5, 2.0)),
dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=(2048, 1024),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
type=dataset_type,
data_root=data_root,
img_dir="leftImg8bit/train",
ann_dir="gtFine/train",
pipeline=train_pipeline,
),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir="leftImg8bit/val",
ann_dir="gtFine/val",
pipeline=test_pipeline,
),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir="leftImg8bit/val",
ann_dir="gtFine/val",
pipeline=test_pipeline,
),
)
38 changes: 38 additions & 0 deletions SegFormer/configs/_base_/datasets/cityscapes_768x768.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_base_ = "./cityscapes.py"
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
crop_size = (768, 768)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations"),
dict(type="Resize", img_scale=(2049, 1025), ratio_range=(0.5, 2.0)),
dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=(2049, 1025),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]
data = dict(
train=dict(pipeline=train_pipeline),
val=dict(pipeline=test_pipeline),
test=dict(pipeline=test_pipeline),
)
38 changes: 38 additions & 0 deletions SegFormer/configs/_base_/datasets/cityscapes_769x769.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_base_ = "./cityscapes.py"
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
crop_size = (769, 769)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations"),
dict(type="Resize", img_scale=(2049, 1025), ratio_range=(0.5, 2.0)),
dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=(2049, 1025),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]
data = dict(
train=dict(pipeline=train_pipeline),
val=dict(pipeline=test_pipeline),
test=dict(pipeline=test_pipeline),
)
Loading

0 comments on commit a53f02a

Please sign in to comment.