Skip to content

Commit e48c7c5

Browse files
committed
beta 1.0
pics downloaded improved; add paras of CD; loading alert improved;
1 parent a3467d6 commit e48c7c5

File tree

9 files changed

+249
-29
lines changed

9 files changed

+249
-29
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
# Intelligent Interpretation of Remote Sensing Images
22

3-
developing...
3+
## Update log
4+
* [2022.6.28] **Beta 1.0 released**: Every basic function has been established.
5+
## TODO
6+
* Multi pictures processing
7+
* Semi-automatic completion of roads extracted
8+
* Smaller and better model of Change Detection
9+
* Slider prediction of Object Classification
10+

functions/change_detection.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def repair(img, o_threshold, h_threshold):
1717
return img_t.astype(int) * 255
1818

1919

20-
def change_detection(A, B, predictor):
20+
def change_detection(A, B, predictor, o_thres, h_thres):
2121
t1 = time.time()
2222
result = predictor.predict(img_file=(A, B))[0]
2323
t2 = time.time()
@@ -28,7 +28,7 @@ def change_detection(A, B, predictor):
2828

2929
result = np.array(result_map, dtype=np.uint8)
3030
result = result * 255
31-
result = repair(result, 200, 200)
31+
result = repair(result, o_thres, h_thres)
3232
# result = repair(result, 200, 1000)
3333
label = (result / 255).astype(int)
3434
score = sum(map(sum, score_map[label == 1])) / (len(score_map[label == 1]) + 1)
@@ -40,10 +40,9 @@ def change_detection(A, B, predictor):
4040

4141
img_a = cv.imread(A)
4242
img_b = cv.imread(B)
43-
alpha_channel = np.ones(img_a.shape[:2], dtype=img_a.dtype) * 125
44-
img_a_al = cv.merge((img_a, alpha_channel))
45-
img_b_al = cv.merge((img_b, alpha_channel))
46-
mixed = cv.add(img_a_al, img_b_al)
47-
mixed = cv.add(mixed, alpha)
43+
img_bo = img_b.copy()
44+
img_b[label == 1] = [1, 0, 255]
45+
mixed = cv.addWeighted(img_bo, 0.5, img_b, 0.5, 1)
46+
mixed = cv.addWeighted(img_a, 0.5, mixed, 0.5, 1)
4847

4948
return result, alpha, score, period, mixed

functions/object_classification.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ def object_classification(img_path, predictor):
9292
len(score_map[types[num][:, :, 3] == 255]) + 1)
9393
areas[num] = len(types[num][types[num][:, :, 3] == 255])
9494

95-
alpha_channel = np.ones(img.shape[:2], dtype=img.dtype) * 255
96-
img_BGRA = cv.merge((img, alpha_channel))
97-
for k in range(4):
98-
img_BGRA = cv.add(img_BGRA, types[k])
99-
100-
return res_img, types, scores, period, areas, img_BGRA
95+
img_a = img.copy()
96+
img_a[label_map == 0] = [0, 0, 255]
97+
img_a[label_map == 1] = [142, 255, 30]
98+
img_a[label_map == 2] = [255, 0, 60]
99+
img_a[label_map == 3] = [0, 222, 255]
100+
mixed = cv.addWeighted(img, 0.3, img_a, 0.7, 1)
101+
mixed = cv.addWeighted(img, 0.3, mixed, 0.7, 1)
102+
103+
return res_img, types, scores, period, areas, mixed

functions/object_extraction.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def object_extraction(img_path, predictor):
2828
res_img = lut[label_map]
2929
roads = add_alpha(res_img)
3030
scores = sum(map(sum, score_map[label_map == 1])) / (len(score_map[label_map == 1]) + 1)
31-
alpha_channel = np.ones(img.shape[:2], dtype=img.dtype) * 255
32-
img_BGRA = cv.merge((img, alpha_channel))
33-
mixed = cv.add(img_BGRA, roads)
31+
32+
img_o = img.copy()
33+
img[label_map == 1] = [1, 0, 255]
34+
mixed = cv.addWeighted(img_o, 0.3, img, 0.7, 1)
35+
mixed = cv.addWeighted(img_o, 0.3, mixed, 0.7, 1)
3436

3537
'''
3638
IoU为0.59,Acc为0.78,Kappa系数为0.72, F1为0.74

process.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
app = Flask(__name__, template_folder="./webpage", static_folder='./webpage', static_url_path="")
1717
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
1818
pro, model, loc, score, period, shape, areas = [0] * 7
19+
o_threshold, h_threshold = [200, 200]
1920

2021

2122
# animation = True
@@ -34,12 +35,14 @@ def welcome():
3435
animation = request.args.get('animation')
3536
return render_template('welcome.html', animation=animation)
3637
elif request.method == 'POST':
37-
global pro, model
38+
global pro, model, o_threshold, h_threshold
3839
pro = request.values['pro']
3940
if pro == '0':
4041
model = load_object_extraction(WEIGHT_FOLDER + '/object_extraction/')
4142
elif pro == '1':
4243
model = load_change_detection(WEIGHT_FOLDER + '/change_detection/')
44+
o_threshold = int(request.values['o_thres'])
45+
h_threshold = int(request.values['h_thres'])
4346
elif pro == '2':
4447
pro_type = int(request.values['type'])
4548
model = load_object_detection(WEIGHT_FOLDER + '/object_detection/' + MODELS[pro_type])
@@ -72,7 +75,7 @@ def upload_file():
7275
B = os.path.join(app.config['UPLOAD_FOLDER'], filename2)
7376
file1.save(A)
7477
file2.save(B)
75-
res, alpha, score, period, mixed = change_detection(A, B, model)
78+
res, alpha, score, period, mixed = change_detection(A, B, model, o_threshold, h_threshold)
7679
shape = list(res.shape)
7780
cv.imwrite(UPLOAD_FOLDER + '/result.png', res)
7881
cv.imwrite(UPLOAD_FOLDER + '/change.png', alpha)

webpage/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<div class="container">
6464
<div class="loader"></div>
6565
<div class="loading_text">解译中</div>
66+
<div class="loading_time"></div>
6667
</div>
6768
</div>
6869
<script>
@@ -99,6 +100,7 @@
99100
const load_bg = document.getElementById('load_bg');
100101
const container = document.getElementsByClassName('container')[0];
101102
const loading_text = document.getElementsByClassName('loading_text')[0];
103+
const loading_time = document.getElementsByClassName('loading_time')[0];
102104
const rs_input = document.getElementById('rs_input');
103105
const rs_input_bg = document.getElementById('rs_input_bg');
104106
const rs_input_txt = document.getElementById('rs_input_txt');
@@ -423,6 +425,8 @@
423425
load_bg.classList.add('show');
424426
container.classList.add('show');
425427
loading_text.classList.add('show');
428+
loading_time.innerHTML = '处理将会耗时一到两分钟';
429+
loading_time.classList.add('show');
426430

427431
let xhr = new XMLHttpRequest();
428432
xhr.open('POST', url, true);
@@ -485,6 +489,10 @@
485489
load_bg.classList.add('show');
486490
container.classList.add('show');
487491
loading_text.classList.add('show');
492+
if (method === 0){
493+
loading_time.innerHTML = '处理将会耗时一到两分钟';
494+
loading_time.classList.add('show');
495+
}
488496

489497
let xhr = new XMLHttpRequest();
490498
xhr.open('POST', url, true);

webpage/styles/index.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,30 @@
408408
line-height: 500px;
409409
}
410410

411+
.loading_time{
412+
position: absolute;
413+
width: 100%;
414+
height: 100%;
415+
line-height: 700px;
416+
text-align: center;
417+
font-size: 20px;
418+
font-family: Ubuntu, "Microsoft YaHei", serif;
419+
font-weight: bold;
420+
color: rgba(0, 0, 0, 0.7);
421+
422+
opacity: 0;
423+
424+
cursor: default;
425+
animation: ease;
426+
transition: all 0.5s 0.5s;
427+
-webkit-transition: all 0.5s 0.5s;
428+
}
429+
430+
.loading_time.show {
431+
line-height: 600px;
432+
opacity: 100%;
433+
}
434+
411435
#rs_input {
412436
width: 250px;
413437
height: 100px;

webpage/styles/wel.css

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@
706706
}
707707

708708
.intro {
709-
background-color: rgba(0, 0, 0, 0.2);
709+
background-color: rgba(255, 255, 255, 0.2);
710710
backdrop-filter: blur(12px);
711711
-webkit-backdrop-filter: blur(12px);
712712
border: 0px solid rgba(255, 255, 255, 0.18);
@@ -844,6 +844,119 @@
844844
color: rgba(255, 255, 255, 0.6);
845845
}
846846

847+
#cd_para_wrapper {
848+
overflow: hidden;
849+
height: 200px;
850+
width: 400px;
851+
position: absolute;
852+
display: flex;
853+
flex-direction: column;
854+
justify-content: right;
855+
align-items: end;
856+
right: 50%;
857+
/*border: 1px black solid;*/
858+
}
859+
860+
.cd_para {
861+
width: 100%;
862+
height: 50px;
863+
display: flex;
864+
justify-content: right;
865+
align-items: end;
866+
867+
cursor: default;
868+
animation: ease-out;
869+
transition: all 0.5s;
870+
-webkit-transition: all 0.5s;
871+
}
872+
873+
.cd_para_name {
874+
background-color: rgba(255, 255, 255, 0.2);
875+
backdrop-filter: blur(12px);
876+
-webkit-backdrop-filter: blur(12px);
877+
border: 0px solid rgba(255, 255, 255, 0.18);
878+
box-shadow: rgba(142, 142, 142, 0.19) 0px 6px 15px 0px;
879+
-webkit-box-shadow: rgba(142, 142, 142, 0.19) 0px 6px 15px 0px;
880+
881+
height: 50px;
882+
padding: 5px;
883+
font-size: 30px;
884+
font-weight: bold;
885+
line-height: 40px;
886+
font-family: Ubuntu, "Microsoft YaHei", serif;
887+
text-align: center;
888+
box-sizing: border-box;
889+
overflow: hidden;
890+
891+
width: 0;
892+
color: rgba(0, 0, 0, 0);
893+
894+
cursor: default;
895+
animation: ease-out;
896+
transition: all 0.5s;
897+
-webkit-transition: all 0.5s;
898+
}
899+
900+
.cd_para_name.show0 {
901+
width: 40%;
902+
color: rgba(0, 0, 0, 0.6);
903+
transition: all 0.5s, width 0.5s 0.6s, color 0.3s 0.9s;
904+
-webkit-transition: all 0.5s, width 0.5s 0.6s, color 0.3s 0.9s;
905+
}
906+
907+
.cd_para_name.show1 {
908+
width: 40%;
909+
color: rgba(0, 0, 0, 0.6);
910+
transition: all 0.5s, width 0.5s 0.7s, color 0.3s 1s;
911+
-webkit-transition: all 0.5s, width 0.5s 0.7s, color 0.3s 1s;
912+
}
913+
914+
.cd_para_name.active{
915+
background-color: rgba(255, 255, 255, 0.7);
916+
}
917+
918+
.cd_para_value {
919+
background-color: rgba(255, 255, 255, 0.4);
920+
backdrop-filter: blur(12px);
921+
-webkit-backdrop-filter: blur(12px);
922+
border: 0px solid rgba(255, 255, 255, 0.18);
923+
box-shadow: rgba(142, 142, 142, 0.19) 0px 6px 15px 0px;
924+
-webkit-box-shadow: rgba(142, 142, 142, 0.19) 0px 6px 15px 0px;
925+
926+
height: 50px;
927+
outline: none;
928+
padding: 5px;
929+
font-size: 30px;
930+
font-weight: bold;
931+
line-height: 40px;
932+
font-family: Ubuntu, "Microsoft YaHei", serif;
933+
text-align: center;
934+
box-sizing: border-box;
935+
overflow: hidden;
936+
937+
width: 0;
938+
color: rgba(0, 0, 0, 0);
939+
940+
cursor: text;
941+
animation: ease-out;
942+
transition: all 0.5s;
943+
-webkit-transition: all 0.5s;
944+
}
945+
946+
.cd_para_value.show0 {
947+
width: 60%;
948+
color: rgba(0, 0, 0, 0.6);
949+
transition: all 0.5s, width 0.5s 0.6s, color 0.3s 0.9s;
950+
-webkit-transition: all 0.5s, width 0.5s 0.6s, color 0.3s 0.9s;
951+
}
952+
953+
.cd_para_value.show1 {
954+
width: 60%;
955+
color: rgba(0, 0, 0, 0.6);
956+
transition: all 0.5s, width 0.5s 0.7s, color 0.3s 1s;
957+
-webkit-transition: all 0.5s, width 0.5s 0.7s, color 0.3s 1s;
958+
}
959+
847960
.go {
848961
background-color: rgba(0, 0, 0, 0.2);
849962
backdrop-filter: blur(12px);

0 commit comments

Comments
 (0)