Skip to content

Commit 00b4c76

Browse files
authored
Add files via upload
1 parent 921ba61 commit 00b4c76

File tree

2 files changed

+45
-54
lines changed

2 files changed

+45
-54
lines changed

datasets/AWSS.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def get_images_paths(self,image_dir, percentage=100, nTrain_samples=None, params
9696
for filename in glob.iglob(image_dir + '/**/RGB_Shaky_Fr_*.png', recursive=True):
9797
if filename.find("RGB_Shaky_Fr_") != -1:
9898
# ------------------------------
99-
img = filename.replace('/home/kerim/Silver_Project/Silver_Recordings/', '')
99+
img = filename.replace('/home/kerim/Silver_Project/AWSS/', '')
100100
temp = img.split('/')
101101
seq_name, frame_name = temp[0], temp[3]
102-
xml_path = '/home/kerim/Silver_Project/Silver_Recordings/' + seq_name + '/Annotations/Textual/TextualInfo.xml'
102+
xml_path = '/home/kerim/Silver_Project/AWSS/' + seq_name + '/Annotations/Textual/TextualInfo.xml'
103103

104104
root_node = ET.parse(xml_path).getroot()
105105

@@ -169,8 +169,8 @@ def __init__(self, root, split='train', mode='fine', target_type='semantic', tra
169169

170170
FLAG = True#for HRNet
171171
if split =="test" and FLAG:
172-
print("".join("{} {}\n".format(x.replace("/home/kerim/Silver_Project/Silver_Recordings/",''),
173-
y.replace("/home/kerim/Silver_Project/Silver_Recordings/",'')) for x, y in zip(self.images, self.targets)))
172+
print("".join("{} {}\n".format(x.replace("/home/kerim/Silver_Project/AWSS/",''),
173+
y.replace("/home/kerim/Silver_Project/AWSS/",'')) for x, y in zip(self.images, self.targets)))
174174

175175
pass
176176
def __len__(self):
@@ -198,10 +198,10 @@ def __getitem__(self, index):
198198

199199
# get the weather and time labels
200200
# ------------------------------
201-
img = self.images[index].replace('/home/kerim/Silver_Project/Silver_Recordings/', '')
201+
img = self.images[index].replace('/home/kerim/Silver_Project/AWSS/', '')
202202
temp = img.split('/')
203203
seq_name, frame_name = temp[0], temp[3]
204-
xml_path = '/home/kerim/Silver_Project/Silver_Recordings/' + seq_name + '/Annotations/Textual/TextualInfo.xml'
204+
xml_path = '/home/kerim/Silver_Project/AWSS/' + seq_name + '/Annotations/Textual/TextualInfo.xml'
205205

206206
root_node = ET.parse(xml_path).getroot()
207207

main.py

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
# The model is weather and time aware!
2+
# This models is trained on: AWSS + CS 1:1
3+
# low level features i.e module.backbone.low_level_features (Atrous Conv.) are frozen when training on CS
4+
# Multi-task learning two losses Segmentation loss and weather_time loss, propagated separtely.
5+
# weather awareness just of the Atrous Convolution
6+
# ------------------------
7+
# Please note that our code is based on DeepLabV3+ pytorch implementation.
8+
# --------------------------
9+
import torch
10+
import torch.nn as nn
11+
import numpy as np
12+
import random
13+
import os
114
from tqdm import tqdm
215
import network
316
import utils
4-
import os
5-
import random
617
import argparse
7-
import numpy as np
8-
918
from torch.utils import data
10-
11-
# from New_Exps.Ours.network.utils import Weather_Classifier
12-
from datasets import VOCSegmentation, Cityscapes, ACDC, AWSS
19+
from datasets import Cityscapes, ACDC, AWSS
1320
from utils import ext_transforms as et
1421
from metrics import StreamSegMetrics
15-
16-
import torch
17-
import torch.nn as nn
1822
from utils.visualizer import Visualizer
19-
2023
from PIL import Image
2124
import matplotlib
2225
import matplotlib.pyplot as plt
@@ -45,7 +48,7 @@ def get_argparser():
4548
parser.add_argument("--output_stride", type=int, default=16, choices=[8, 16])
4649

4750
# Train Options
48-
parser.add_argument("--test_only", action='store_true', default=False)#Change from False to True Kerim
51+
parser.add_argument("--test_only", action='store_true', default=False)
4952
parser.add_argument("--save_val_results", action='store_true', default=True,
5053
help="save segmentation results to \"./results\"")
5154
parser.add_argument("--total_itrs", type=int, default=30e3,
@@ -254,15 +257,12 @@ def main(ACDC_test_class = None,n_itrs=10000000,MODE=12345):
254257
opts.ACDC_test_class = ACDC_test_class
255258
opts.finetune = False
256259
opts.pretrained_model = None
257-
# MODE = 0#train on cityscapes
258-
# MODE = 1#finetune pretrained cityscapes on AWSS
259-
# MODE = 10#test on cityscapes
260+
# MODE = 0#train on cityscapes and AWSS
260261
# MODE = 11#test on cityscapes
261-
# MODE = 20#test on acdc
262-
# MODE = 21 # test on acdc
263-
opts.data_root_cs = "/home/kerim/DataSets/SemanticSegmentation/cityscapes"
264-
opts.data_root_acdc = "/home/kerim/DataSets/SemanticSegmentation/ACDC"
265-
opts.data_root_awss = "/home/kerim/Silver_Project/Silver_Recordings"
262+
# MODE = 21#test on acdc
263+
opts.data_root_cs = "/home/kerim/DataSets/SemanticSegmentation/cityscapes"#Update as necessary
264+
opts.data_root_acdc = "/home/kerim/DataSets/SemanticSegmentation/ACDC"#Update as necessary
265+
opts.data_root_awss = "/home/kerim/Silver_Project/AWSS"#Update as necessary
266266
opts.total_itrs = n_itrs
267267
opts.test_class = None
268268
opts.val_batch_size = 8
@@ -293,9 +293,6 @@ def main(ACDC_test_class = None,n_itrs=10000000,MODE=12345):
293293
opts.batch_size = 4
294294
opts.output_stride = 16
295295
opts.crop_val = True
296-
# opts.val_interval = 2
297-
298-
# opts.num_classes = 11
299296

300297

301298
if opts.dataset.lower() == 'voc':
@@ -599,7 +596,6 @@ def save_ckpt(path):
599596
if cur_itrs >= opts.total_itrs:
600597
return
601598

602-
# The model is ours V01
603599
if __name__ == '__main__':
604600

605601
ACDC_classes = ['rain','fog','snow','night']
@@ -613,47 +609,42 @@ def save_ckpt(path):
613609
exit()
614610
main(MODE=MODE)
615611

616-
# --------------------------------------------------------------- V02 --------------
617-
# V02: The model is weather and time aware!
618-
# This models is trained on: AWSS + CS 1:1
619-
# low level features i.e module.backbone.low_level_features (Atrous Conv.) are frozen when training on CS
620-
# Multi-task learning two losses Segmentation loss and weather_time loss, propagated separtely.
621-
# weather awareness just of the Atrous Convolution
622-
# --------------------------------------------------------------- CS
612+
# Expected Output
613+
# =================
614+
# Cityscapes
615+
# ------------
623616
# Overall Acc: 0.939875
624617
# Mean Acc: 0.825837
625618
# FreqW Acc: 0.890178
626619
# Mean IoU: 0.746920
627-
#
628-
# [0.95335767 0.72550871 0.88743945 0.50785172 0.44274712 0.60158601 0.87598127 0.87561615 0.70870125 0.89040882]
629-
# ------------------------------------------------------------------- ACDC
630-
620+
# Per-class IoU: [0.95335767 0.72550871 0.88743945 0.50785172 0.44274712 0.60158601 0.87598127 0.87561615 0.70870125 0.89040882]
621+
# -------------------------------------------------------------------
622+
# ACDC
623+
# ------------
624+
# ACDC (Rain)
631625
# Overall Acc: 0.877963
632626
# Mean Acc: 0.667648
633627
# FreqW Acc: 0.791779
634628
# Mean IoU: 0.566379
635-
#
636-
# [0.76403344 0.36642211 0.72458654 0.31330346 0.32441966 0.40964191 0.81764442 0.9160704 0.40519023 0.62248053]
637-
629+
# Per-class IoU: [0.76403344 0.36642211 0.72458654 0.31330346 0.32441966 0.40964191 0.81764442 0.9160704 0.40519023 0.62248053]
630+
# ---
631+
# ACDC (Fog)
638632
# Overall Acc: 0.899750
639633
# Mean Acc: 0.697483
640634
# FreqW Acc: 0.826015
641635
# Mean IoU: 0.599675
642-
#
643-
# [0.89968568 0.61364265 0.72526159 0.30592753 0.36195622 0.40860551 0.82659963 0.91106372 0.34895574 0.59505032]
644-
636+
# Per-class IoU: [0.89968568 0.61364265 0.72526159 0.30592753 0.36195622 0.40860551 0.82659963 0.91106372 0.34895574 0.59505032]
637+
# ---
638+
# ACDC (Snow)
645639
# Overall Acc: 0.813452
646640
# Mean Acc: 0.597240
647641
# FreqW Acc: 0.690171
648642
# Mean IoU: 0.502845
649-
#
650-
# [0.72744211 0.27268236 0.63459407 0.28343183 0.2544351 0.42002753 0.75314912 0.75577437 0.34386931 0.58304499]
651-
643+
# Per-class IoU: [0.72744211 0.27268236 0.63459407 0.28343183 0.2544351 0.42002753 0.75314912 0.75577437 0.34386931 0.58304499]
644+
# ---
645+
# ACDC (Night)
652646
# Overall Acc: 0.589835
653647
# Mean Acc: 0.365503
654648
# FreqW Acc: 0.423166
655649
# Mean IoU: 0.271261
656-
#
657-
# [0.75924663 0.34913799 0.43090425 0.08629936 0.10791564 0.08757231 0.37398767 0.04645397 0.18224199 0.28884528]
658-
659-
650+
# Per-class IoU: [0.75924663 0.34913799 0.43090425 0.08629936 0.10791564 0.08757231 0.37398767 0.04645397 0.18224199 0.28884528]

0 commit comments

Comments
 (0)