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

Octavio #14

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file added PrediccionesDeepLab/201966_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesDeepLab/298983_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesDeepLab/650673_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesDeepLab/802551_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesDeepLab/896504_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesHRNet/201966_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesHRNet/298983_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesHRNet/650673_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesHRNet/802551_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PrediccionesHRNet/896504_sat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions configs/_base_/models/deeplabv3_r50-d8_deepGlobe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#configs/_base_/models/deeplabv3_r50-d8.py
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
data_preprocessor = dict(
type='SegDataPreProcessor',
mean=[0.4082, 0.3791, 0.2815],
std=[ 0.1451, 0.1116, 0.1013],
bgr_to_rgb=True,
pad_val=0,
seg_pad_val=255)
model = dict(
type='EncoderDecoder',
data_preprocessor=data_preprocessor,
pretrained='open-mmlab://resnet50_v1c',
backbone=dict(
type='ResNetV1c',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=(1, 2, 1, 1),
norm_cfg=norm_cfg,
norm_eval=False,
style='pytorch',
contract_dilation=True),
decode_head=dict(
type='ASPPHead',
in_channels=2048,
in_index=3,
channels=512,
dilations=(1, 12, 24, 36),
dropout_ratio=0.1,
num_classes=7,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
auxiliary_head=dict(
type='FCNHead',
in_channels=1024,
in_index=2,
channels=256,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=7,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode='whole'))
20 changes: 14 additions & 6 deletions tools/model_test.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@


import os
import mmcv
import numpy as np
import cv2
from mmseg.apis import init_model, inference_model

# Configuration and checkpoint paths
CONFIG_FILE = '/Users/anyego/Desktop/mmsegmentationEQ2/configs/fcn/fcn_r18-d8_4xb2-80k_deepglobe-512x1024.py'
CHECKPOINT_FILE = '/Users/anyego/Desktop/mmsegmentationEQ2/workdir/fcn/iter_10000.pth'
CONFIG_FILE = '/Users/octaviofenollosa/GithubWeb/AIDeep/mmsegmentationEQ2/configs/hrnet/fcn_hr18_4xb2-40k_deepglobe-512x1024.py'
CHECKPOINT_FILE = '/Users/octaviofenollosa/GithubWeb/AIDeep/mmsegmentationEQ2/work-dir/HRNet/iter_10000.pth'
DEVICE = 'cpu'



# Custom color palette
PALETTE = np.array([
[0, 255, 255], [255, 255, 0], [255, 0, 255],
[0, 255, 0], [0, 0, 255], [255, 255, 255],
[0, 255, 255],
[255, 255, 0],
[255, 0, 255],
[0, 255, 0],
[0, 0, 255],
[255, 255, 255],
[0, 0, 0]
], dtype=np.uint8)

# Directories
IMAGE_DIR = '/Users/anyego/Desktop/mmsegmentationEQ2/Test_model'
OUTPUT_DIR = '/Users/anyego/Desktop/mmsegmentationEQ2/PrediccionesFCN'
IMAGE_DIR = '/Users/octaviofenollosa/GithubWeb/AIDeep/mmsegmentationEQ2/Test_model'
OUTPUT_DIR = '/Users/octaviofenollosa/GithubWeb/AIDeep/mmsegmentationEQ2/PrediccionesHRNet'

def initialize_model(config_path, checkpoint_path, device):
"""Initialize the segmentation model."""
Expand Down
211 changes: 211 additions & 0 deletions work-dir/DeepLab/20240605_012836/vis_data/20240605_012836.json

Large diffs are not rendered by default.

299 changes: 299 additions & 0 deletions work-dir/DeepLab/20240605_012836/vis_data/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
crop_size = (
256,
256,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
0.4082,
0.3791,
0.2815,
],
pad_val=0,
seg_pad_val=255,
size=(
256,
256,
),
std=[
0.1351,
0.1022,
0.0931,
],
type='SegDataPreProcessor')
data_root = 'data/deepglobe_ds/'
dataset_type = 'DeepGlobeDataset'
default_hooks = dict(
checkpoint=dict(by_epoch=False, interval=4000, type='CheckpointHook'),
logger=dict(interval=50, log_metric_by_epoch=False, type='LoggerHook'),
param_scheduler=dict(type='ParamSchedulerHook'),
sampler_seed=dict(type='DistSamplerSeedHook'),
timer=dict(type='IterTimerHook'),
visualization=dict(type='SegVisualizationHook'))
default_scope = 'mmseg'
env_cfg = dict(
cudnn_benchmark=True,
dist_cfg=dict(backend='nccl'),
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
img_ratios = [
0.5,
0.75,
1.0,
1.25,
1.5,
1.75,
]
launcher = 'none'
load_from = None
log_level = 'INFO'
log_processor = dict(by_epoch=False)
model = dict(
auxiliary_head=dict(
align_corners=False,
channels=256,
concat_input=False,
dropout_ratio=0.1,
in_channels=1024,
in_index=2,
loss_decode=dict(
loss_weight=0.4, type='CrossEntropyLoss', use_sigmoid=False),
norm_cfg=dict(requires_grad=True, type='SyncBN'),
num_classes=7,
num_convs=1,
type='FCNHead'),
backbone=dict(
contract_dilation=True,
depth=50,
dilations=(
1,
1,
2,
4,
),
norm_cfg=dict(requires_grad=True, type='SyncBN'),
norm_eval=False,
num_stages=4,
out_indices=(
0,
1,
2,
3,
),
strides=(
1,
2,
1,
1,
),
style='pytorch',
type='ResNetV1c'),
data_preprocessor=dict(
bgr_to_rgb=True,
mean=[
0.4082,
0.3791,
0.2815,
],
pad_val=0,
seg_pad_val=255,
size=(
256,
256,
),
std=[
0.1351,
0.1022,
0.0931,
],
type='SegDataPreProcessor'),
decode_head=dict(
align_corners=False,
channels=512,
dilations=(
1,
12,
24,
36,
),
dropout_ratio=0.1,
in_channels=2048,
in_index=3,
loss_decode=dict(
loss_weight=1.0, type='CrossEntropyLoss', use_sigmoid=False),
norm_cfg=dict(requires_grad=True, type='SyncBN'),
num_classes=7,
type='ASPPHead'),
pretrained='open-mmlab://resnet50_v1c',
test_cfg=dict(mode='whole'),
train_cfg=dict(),
type='EncoderDecoder')
norm_cfg = dict(requires_grad=True, type='SyncBN')
optim_wrapper = dict(
clip_grad=None,
optimizer=dict(lr=0.01, momentum=0.9, type='SGD', weight_decay=0.0005),
type='OptimWrapper')
optimizer = dict(lr=0.01, momentum=0.9, type='SGD', weight_decay=0.0005)
param_scheduler = [
dict(
begin=0,
by_epoch=False,
end=10000,
eta_min=0.0001,
power=0.9,
type='PolyLR'),
]
resume = False
test_cfg = dict(type='TestLoop')
test_dataloader = dict(
batch_size=8,
dataset=dict(
data_prefix=dict(
img_path='img_dir/val_sat',
seg_map_path='ann_dir/val_mask_grayscale'),
data_root='data/deepglobe_ds/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(keep_ratio=True, scale=(
512,
512,
), type='Resize'),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs'),
],
type='DeepGlobeDataset'),
num_workers=4,
persistent_workers=True,
sampler=dict(shuffle=False, type='DefaultSampler'))
test_evaluator = dict(
iou_metrics=[
'mIoU',
], type='IoUMetric')
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(keep_ratio=True, scale=(
512,
512,
), type='Resize'),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs'),
]
train_cfg = dict(max_iters=10000, type='IterBasedTrainLoop', val_interval=1000)
train_dataloader = dict(
batch_size=32,
dataset=dict(
data_prefix=dict(
img_path='img_dir/train_sat',
seg_map_path='ann_dir/train_mask_grayscale'),
data_root='data/deepglobe_ds/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(
keep_ratio=True,
ratio_range=(
0.5,
2.0,
),
scale=(
512,
512,
),
type='RandomResize'),
dict(
cat_max_ratio=0.75, crop_size=(
256,
256,
), type='RandomCrop'),
dict(prob=0.5, type='RandomFlip'),
dict(type='PhotoMetricDistortion'),
dict(type='PackSegInputs'),
],
type='DeepGlobeDataset'),
num_workers=4,
persistent_workers=True,
sampler=dict(shuffle=True, type='InfiniteSampler'))
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations'),
dict(
keep_ratio=True,
ratio_range=(
0.5,
2.0,
),
scale=(
512,
512,
),
type='RandomResize'),
dict(cat_max_ratio=0.75, crop_size=(
256,
256,
), type='RandomCrop'),
dict(prob=0.5, type='RandomFlip'),
dict(type='PhotoMetricDistortion'),
dict(type='PackSegInputs'),
]
tta_model = dict(type='SegTTAModel')
tta_pipeline = [
dict(backend_args=None, type='LoadImageFromFile'),
dict(
transforms=[
[
dict(keep_ratio=True, scale_factor=0.5, type='Resize'),
dict(keep_ratio=True, scale_factor=0.75, type='Resize'),
dict(keep_ratio=True, scale_factor=1.0, type='Resize'),
dict(keep_ratio=True, scale_factor=1.25, type='Resize'),
dict(keep_ratio=True, scale_factor=1.5, type='Resize'),
dict(keep_ratio=True, scale_factor=1.75, type='Resize'),
],
[
dict(direction='horizontal', prob=0.0, type='RandomFlip'),
dict(direction='horizontal', prob=1.0, type='RandomFlip'),
],
[
dict(type='LoadAnnotations'),
],
[
dict(type='PackSegInputs'),
],
],
type='TestTimeAug'),
]
val_cfg = dict(type='ValLoop')
val_dataloader = dict(
batch_size=8,
dataset=dict(
data_prefix=dict(
img_path='img_dir/val_sat',
seg_map_path='ann_dir/val_mask_grayscale'),
data_root='data/deepglobe_ds/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(keep_ratio=True, scale=(
512,
512,
), type='Resize'),
dict(type='LoadAnnotations'),
dict(type='PackSegInputs'),
],
type='DeepGlobeDataset'),
num_workers=4,
persistent_workers=True,
sampler=dict(shuffle=False, type='DefaultSampler'))
val_evaluator = dict(
iou_metrics=[
'mIoU',
], type='IoUMetric')
vis_backends = [
dict(type='LocalVisBackend'),
dict(type='TensorboardVisBackend'),
]
visualizer = dict(
name='visualizer',
type='SegLocalVisualizer',
vis_backends=[
dict(type='LocalVisBackend'),
dict(type='TensorboardVisBackend'),
])
work_dir = '/content/drive/MyDrive/Equipo2AI/work-dir/DeepLab'
Binary file not shown.
Loading