Skip to content

Commit

Permalink
testCode
Browse files Browse the repository at this point in the history
  • Loading branch information
AWCXV committed Oct 14, 2024
1 parent a696fee commit 35de693
Show file tree
Hide file tree
Showing 806 changed files with 1,195 additions and 6 deletions.
Binary file added DenseFuse.model
Binary file not shown.
Binary file added LLVIP_test250_DDcGAN/1.png
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 LLVIP_test250_DDcGAN/10.png
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 LLVIP_test250_DDcGAN/100.png
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 LLVIP_test250_DDcGAN/101.png
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 LLVIP_test250_DDcGAN/102.png
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 LLVIP_test250_DDcGAN/103.png
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 LLVIP_test250_DDcGAN/104.png
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 LLVIP_test250_DDcGAN/105.png
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 LLVIP_test250_DDcGAN/106.png
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 LLVIP_test250_DDcGAN/107.png
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 LLVIP_test250_DDcGAN/108.png
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 LLVIP_test250_DDcGAN/109.png
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 LLVIP_test250_DDcGAN/11.png
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 LLVIP_test250_DDcGAN/110.png
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 LLVIP_test250_DDcGAN/111.png
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 LLVIP_test250_DDcGAN/112.png
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 LLVIP_test250_DDcGAN/113.png
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 LLVIP_test250_DDcGAN/114.png
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 LLVIP_test250_DDcGAN/115.png
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 LLVIP_test250_DDcGAN/116.png
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 LLVIP_test250_DDcGAN/117.png
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 LLVIP_test250_DDcGAN/118.png
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 LLVIP_test250_DDcGAN/119.png
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 LLVIP_test250_DDcGAN/12.png
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 LLVIP_test250_DDcGAN/120.png
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 LLVIP_test250_DDcGAN/121.png
Binary file added LLVIP_test250_DDcGAN/122.png
Binary file added LLVIP_test250_DDcGAN/123.png
Binary file added LLVIP_test250_DDcGAN/124.png
Binary file added LLVIP_test250_DDcGAN/125.png
Binary file added LLVIP_test250_DDcGAN/126.png
Binary file added LLVIP_test250_DDcGAN/127.png
Binary file added LLVIP_test250_DDcGAN/128.png
Binary file added LLVIP_test250_DDcGAN/129.png
Binary file added LLVIP_test250_DDcGAN/13.png
Binary file added LLVIP_test250_DDcGAN/130.png
Binary file added LLVIP_test250_DDcGAN/131.png
Binary file added LLVIP_test250_DDcGAN/132.png
Binary file added LLVIP_test250_DDcGAN/133.png
Binary file added LLVIP_test250_DDcGAN/134.png
Binary file added LLVIP_test250_DDcGAN/135.png
Binary file added LLVIP_test250_DDcGAN/136.png
Binary file added LLVIP_test250_DDcGAN/137.png
Binary file added LLVIP_test250_DDcGAN/138.png
Binary file added LLVIP_test250_DDcGAN/139.png
Binary file added LLVIP_test250_DDcGAN/14.png
Binary file added LLVIP_test250_DDcGAN/140.png
Binary file added LLVIP_test250_DDcGAN/141.png
Binary file added LLVIP_test250_DDcGAN/142.png
Binary file added LLVIP_test250_DDcGAN/143.png
Binary file added LLVIP_test250_DDcGAN/144.png
Binary file added LLVIP_test250_DDcGAN/145.png
Binary file added LLVIP_test250_DDcGAN/146.png
Binary file added LLVIP_test250_DDcGAN/147.png
Binary file added LLVIP_test250_DDcGAN/148.png
Binary file added LLVIP_test250_DDcGAN/149.png
Binary file added LLVIP_test250_DDcGAN/15.png
Binary file added LLVIP_test250_DDcGAN/150.png
Binary file added LLVIP_test250_DDcGAN/151.png
Binary file added LLVIP_test250_DDcGAN/152.png
Binary file added LLVIP_test250_DDcGAN/153.png
Binary file added LLVIP_test250_DDcGAN/154.png
Binary file added LLVIP_test250_DDcGAN/155.png
Binary file added LLVIP_test250_DDcGAN/156.png
Binary file added LLVIP_test250_DDcGAN/157.png
Binary file added LLVIP_test250_DDcGAN/158.png
Binary file added LLVIP_test250_DDcGAN/159.png
Binary file added LLVIP_test250_DDcGAN/16.png
Binary file added LLVIP_test250_DDcGAN/160.png
Binary file added LLVIP_test250_DDcGAN/161.png
Binary file added LLVIP_test250_DDcGAN/162.png
Binary file added LLVIP_test250_DDcGAN/163.png
Binary file added LLVIP_test250_DDcGAN/164.png
Binary file added LLVIP_test250_DDcGAN/165.png
Binary file added LLVIP_test250_DDcGAN/166.png
Binary file added LLVIP_test250_DDcGAN/167.png
Binary file added LLVIP_test250_DDcGAN/168.png
Binary file added LLVIP_test250_DDcGAN/169.png
Binary file added LLVIP_test250_DDcGAN/17.png
Binary file added LLVIP_test250_DDcGAN/170.png
Binary file added LLVIP_test250_DDcGAN/171.png
Binary file added LLVIP_test250_DDcGAN/172.png
Binary file added LLVIP_test250_DDcGAN/173.png
Binary file added LLVIP_test250_DDcGAN/174.png
Binary file added LLVIP_test250_DDcGAN/175.png
Binary file added LLVIP_test250_DDcGAN/176.png
Binary file added LLVIP_test250_DDcGAN/177.png
Binary file added LLVIP_test250_DDcGAN/178.png
Binary file added LLVIP_test250_DDcGAN/179.png
Binary file added LLVIP_test250_DDcGAN/18.png
Binary file added LLVIP_test250_DDcGAN/180.png
Binary file added LLVIP_test250_DDcGAN/181.png
Binary file added LLVIP_test250_DDcGAN/182.png
Binary file added LLVIP_test250_DDcGAN/183.png
Binary file added LLVIP_test250_DDcGAN/184.png
Binary file added LLVIP_test250_DDcGAN/185.png
Binary file added LLVIP_test250_DDcGAN/186.png
Binary file added LLVIP_test250_DDcGAN/187.png
Binary file added LLVIP_test250_DDcGAN/188.png
Binary file added LLVIP_test250_DDcGAN/189.png
Binary file added LLVIP_test250_DDcGAN/19.png
Binary file added LLVIP_test250_DDcGAN/190.png
Binary file added LLVIP_test250_DDcGAN/191.png
Binary file added LLVIP_test250_DDcGAN/192.png
Binary file added LLVIP_test250_DDcGAN/193.png
Binary file added LLVIP_test250_DDcGAN/194.png
Binary file added LLVIP_test250_DDcGAN/195.png
Binary file added LLVIP_test250_DDcGAN/196.png
Binary file added LLVIP_test250_DDcGAN/197.png
Binary file added LLVIP_test250_DDcGAN/198.png
Binary file added LLVIP_test250_DDcGAN/199.png
Binary file added LLVIP_test250_DDcGAN/2.png
Binary file added LLVIP_test250_DDcGAN/20.png
Binary file added LLVIP_test250_DDcGAN/200.png
Binary file added LLVIP_test250_DDcGAN/201.png
Binary file added LLVIP_test250_DDcGAN/202.png
Binary file added LLVIP_test250_DDcGAN/203.png
Binary file added LLVIP_test250_DDcGAN/204.png
Binary file added LLVIP_test250_DDcGAN/205.png
Binary file added LLVIP_test250_DDcGAN/206.png
Binary file added LLVIP_test250_DDcGAN/207.png
Binary file added LLVIP_test250_DDcGAN/208.png
Binary file added LLVIP_test250_DDcGAN/209.png
Binary file added LLVIP_test250_DDcGAN/21.png
Binary file added LLVIP_test250_DDcGAN/210.png
Binary file added LLVIP_test250_DDcGAN/211.png
Binary file added LLVIP_test250_DDcGAN/212.png
Binary file added LLVIP_test250_DDcGAN/213.png
Binary file added LLVIP_test250_DDcGAN/214.png
Binary file added LLVIP_test250_DDcGAN/215.png
Binary file added LLVIP_test250_DDcGAN/216.png
Binary file added LLVIP_test250_DDcGAN/217.png
Binary file added LLVIP_test250_DDcGAN/218.png
Binary file added LLVIP_test250_DDcGAN/219.png
Binary file added LLVIP_test250_DDcGAN/22.png
Binary file added LLVIP_test250_DDcGAN/220.png
Binary file added LLVIP_test250_DDcGAN/221.png
Binary file added LLVIP_test250_DDcGAN/222.png
Binary file added LLVIP_test250_DDcGAN/223.png
Binary file added LLVIP_test250_DDcGAN/224.png
Binary file added LLVIP_test250_DDcGAN/225.png
Binary file added LLVIP_test250_DDcGAN/226.png
Binary file added LLVIP_test250_DDcGAN/227.png
Binary file added LLVIP_test250_DDcGAN/228.png
Binary file added LLVIP_test250_DDcGAN/229.png
Binary file added LLVIP_test250_DDcGAN/23.png
Binary file added LLVIP_test250_DDcGAN/230.png
Binary file added LLVIP_test250_DDcGAN/231.png
Binary file added LLVIP_test250_DDcGAN/232.png
Binary file added LLVIP_test250_DDcGAN/233.png
Binary file added LLVIP_test250_DDcGAN/234.png
Binary file added LLVIP_test250_DDcGAN/235.png
Binary file added LLVIP_test250_DDcGAN/236.png
Binary file added LLVIP_test250_DDcGAN/237.png
Binary file added LLVIP_test250_DDcGAN/238.png
Binary file added LLVIP_test250_DDcGAN/239.png
Binary file added LLVIP_test250_DDcGAN/24.png
Binary file added LLVIP_test250_DDcGAN/240.png
Binary file added LLVIP_test250_DDcGAN/241.png
Binary file added LLVIP_test250_DDcGAN/242.png
Binary file added LLVIP_test250_DDcGAN/243.png
Binary file added LLVIP_test250_DDcGAN/244.png
Binary file added LLVIP_test250_DDcGAN/245.png
Binary file added LLVIP_test250_DDcGAN/246.png
Binary file added LLVIP_test250_DDcGAN/247.png
Binary file added LLVIP_test250_DDcGAN/248.png
Binary file added LLVIP_test250_DDcGAN/249.png
Binary file added LLVIP_test250_DDcGAN/25.png
Binary file added LLVIP_test250_DDcGAN/250.png
Binary file added LLVIP_test250_DDcGAN/26.png
Binary file added LLVIP_test250_DDcGAN/27.png
Binary file added LLVIP_test250_DDcGAN/28.png
Binary file added LLVIP_test250_DDcGAN/29.png
Binary file added LLVIP_test250_DDcGAN/3.png
Binary file added LLVIP_test250_DDcGAN/30.png
Binary file added LLVIP_test250_DDcGAN/31.png
Binary file added LLVIP_test250_DDcGAN/32.png
Binary file added LLVIP_test250_DDcGAN/33.png
Binary file added LLVIP_test250_DDcGAN/34.png
Binary file added LLVIP_test250_DDcGAN/35.png
Binary file added LLVIP_test250_DDcGAN/36.png
Binary file added LLVIP_test250_DDcGAN/37.png
Binary file added LLVIP_test250_DDcGAN/38.png
Binary file added LLVIP_test250_DDcGAN/39.png
Binary file added LLVIP_test250_DDcGAN/4.png
Binary file added LLVIP_test250_DDcGAN/40.png
Binary file added LLVIP_test250_DDcGAN/41.png
Binary file added LLVIP_test250_DDcGAN/42.png
Binary file added LLVIP_test250_DDcGAN/43.png
Binary file added LLVIP_test250_DDcGAN/44.png
Binary file added LLVIP_test250_DDcGAN/45.png
Binary file added LLVIP_test250_DDcGAN/46.png
Binary file added LLVIP_test250_DDcGAN/47.png
Binary file added LLVIP_test250_DDcGAN/48.png
Binary file added LLVIP_test250_DDcGAN/49.png
Binary file added LLVIP_test250_DDcGAN/5.png
Binary file added LLVIP_test250_DDcGAN/50.png
Binary file added LLVIP_test250_DDcGAN/51.png
Binary file added LLVIP_test250_DDcGAN/52.png
Binary file added LLVIP_test250_DDcGAN/53.png
Binary file added LLVIP_test250_DDcGAN/54.png
Binary file added LLVIP_test250_DDcGAN/55.png
Binary file added LLVIP_test250_DDcGAN/56.png
Binary file added LLVIP_test250_DDcGAN/57.png
Binary file added LLVIP_test250_DDcGAN/58.png
Binary file added LLVIP_test250_DDcGAN/59.png
Binary file added LLVIP_test250_DDcGAN/6.png
Binary file added LLVIP_test250_DDcGAN/60.png
Binary file added LLVIP_test250_DDcGAN/61.png
Binary file added LLVIP_test250_DDcGAN/62.png
Binary file added LLVIP_test250_DDcGAN/63.png
Binary file added LLVIP_test250_DDcGAN/64.png
Binary file added LLVIP_test250_DDcGAN/65.png
Binary file added LLVIP_test250_DDcGAN/66.png
Binary file added LLVIP_test250_DDcGAN/67.png
Binary file added LLVIP_test250_DDcGAN/68.png
Binary file added LLVIP_test250_DDcGAN/69.png
Binary file added LLVIP_test250_DDcGAN/7.png
Binary file added LLVIP_test250_DDcGAN/70.png
Binary file added LLVIP_test250_DDcGAN/71.png
Binary file added LLVIP_test250_DDcGAN/72.png
Binary file added LLVIP_test250_DDcGAN/73.png
Binary file added LLVIP_test250_DDcGAN/74.png
Binary file added LLVIP_test250_DDcGAN/75.png
Binary file added LLVIP_test250_DDcGAN/76.png
Binary file added LLVIP_test250_DDcGAN/77.png
Binary file added LLVIP_test250_DDcGAN/78.png
Binary file added LLVIP_test250_DDcGAN/79.png
Binary file added LLVIP_test250_DDcGAN/8.png
Binary file added LLVIP_test250_DDcGAN/80.png
Binary file added LLVIP_test250_DDcGAN/81.png
Binary file added LLVIP_test250_DDcGAN/82.png
Binary file added LLVIP_test250_DDcGAN/83.png
Binary file added LLVIP_test250_DDcGAN/84.png
Binary file added LLVIP_test250_DDcGAN/85.png
Binary file added LLVIP_test250_DDcGAN/86.png
Binary file added LLVIP_test250_DDcGAN/87.png
Binary file added LLVIP_test250_DDcGAN/88.png
Binary file added LLVIP_test250_DDcGAN/89.png
Binary file added LLVIP_test250_DDcGAN/9.png
Binary file added LLVIP_test250_DDcGAN/90.png
Binary file added LLVIP_test250_DDcGAN/91.png
Binary file added LLVIP_test250_DDcGAN/92.png
Binary file added LLVIP_test250_DDcGAN/93.png
Binary file added LLVIP_test250_DDcGAN/94.png
Binary file added LLVIP_test250_DDcGAN/95.png
Binary file added LLVIP_test250_DDcGAN/96.png
Binary file added LLVIP_test250_DDcGAN/97.png
Binary file added LLVIP_test250_DDcGAN/98.png
Binary file added LLVIP_test250_DDcGAN/99.png
Binary file added LLVIP_test250_DDcGAN/LLVIP250_resized.mat
Binary file not shown.
22 changes: 22 additions & 0 deletions LLVIP_test250_DDcGAN/batch_change_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import time
import shutil

def main():

test_path = "./"
output_path = './';
# if mode == 'L':
# image = imread(path, mode=mode)
# elif mode == 'RGB':
# image = Image.open(path).convert('RGB')
num_imgs = 50;
for i in range(1,1+num_imgs):
print('processing '+str(i)+'-th image...');
fileNameA = str(i)+'.png';
fileNameB = str(200+i)+'.png';

os.rename(fileNameA,fileNameB);

if __name__ == '__main__':
main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added LLVIP_test250_DDcGAN/promisingResults.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
158 changes: 158 additions & 0 deletions Myloss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torchvision.models.vgg import vgg16
import numpy as np
from args_fusion import args


class L_color(nn.Module):

def __init__(self):
super(L_color, self).__init__()

def forward(self, x ):

b,c,h,w = x.shape

mean_rgb = torch.mean(x,[2,3],keepdim=True)
mr,mg, mb = torch.split(mean_rgb, 1, dim=1)
Drg = torch.pow(mr-mg,2)
Drb = torch.pow(mr-mb,2)
Dgb = torch.pow(mb-mg,2)
k = torch.pow(torch.pow(Drg,2) + torch.pow(Drb,2) + torch.pow(Dgb,2),0.5)


return k


class L_spa(nn.Module):

def __init__(self):
super(L_spa, self).__init__()
# print(1)kernel = torch.FloatTensor(kernel).unsqueeze(0).unsqueeze(0)
kernel_left = torch.FloatTensor( [[0,0,0],[-1,1,0],[0,0,0]]).cuda(args.device).unsqueeze(0).unsqueeze(0)
kernel_right = torch.FloatTensor( [[0,0,0],[0,1,-1],[0,0,0]]).cuda(args.device).unsqueeze(0).unsqueeze(0)
kernel_up = torch.FloatTensor( [[0,-1,0],[0,1, 0 ],[0,0,0]]).cuda(args.device).unsqueeze(0).unsqueeze(0)
kernel_down = torch.FloatTensor( [[0,0,0],[0,1, 0],[0,-1,0]]).cuda(args.device).unsqueeze(0).unsqueeze(0)
self.weight_left = nn.Parameter(data=kernel_left, requires_grad=False)
self.weight_right = nn.Parameter(data=kernel_right, requires_grad=False)
self.weight_up = nn.Parameter(data=kernel_up, requires_grad=False)
self.weight_down = nn.Parameter(data=kernel_down, requires_grad=False)
self.pool = nn.AvgPool2d(4)
def forward(self, org , enhance ):
b,c,h,w = org.shape

org_mean = torch.mean(org,1,keepdim=True)
enhance_mean = torch.mean(enhance,1,keepdim=True)

org_pool = self.pool(org_mean)
enhance_pool = self.pool(enhance_mean)

weight_diff =torch.max(torch.FloatTensor([1]).cuda(args.device) + 10000*torch.min(org_pool - torch.FloatTensor([0.3]).cuda(args.device),torch.FloatTensor([0]).cuda(args.device)),torch.FloatTensor([0.5]).cuda(args.device))
E_1 = torch.mul(torch.sign(enhance_pool - torch.FloatTensor([0.5]).cuda(args.device)) ,enhance_pool-org_pool)


D_org_letf = F.conv2d(org_pool , self.weight_left, padding=1)
D_org_right = F.conv2d(org_pool , self.weight_right, padding=1)
D_org_up = F.conv2d(org_pool , self.weight_up, padding=1)
D_org_down = F.conv2d(org_pool , self.weight_down, padding=1)

D_enhance_letf = F.conv2d(enhance_pool , self.weight_left, padding=1)
D_enhance_right = F.conv2d(enhance_pool , self.weight_right, padding=1)
D_enhance_up = F.conv2d(enhance_pool , self.weight_up, padding=1)
D_enhance_down = F.conv2d(enhance_pool , self.weight_down, padding=1)

D_left = torch.pow(D_org_letf - D_enhance_letf,2)
D_right = torch.pow(D_org_right - D_enhance_right,2)
D_up = torch.pow(D_org_up - D_enhance_up,2)
D_down = torch.pow(D_org_down - D_enhance_down,2)
E = (D_left + D_right + D_up +D_down)
# E = 25*(D_left + D_right + D_up +D_down)

return E
class L_exp(nn.Module):

def __init__(self,patch_size,mean_val):
super(L_exp, self).__init__()
# print(1)
self.pool = nn.AvgPool2d(patch_size)
self.mean_val = mean_val
def forward(self, x ):

b,c,h,w = x.shape
x = torch.mean(x,1,keepdim=True)
mean = self.pool(x)

d = torch.mean(torch.pow(mean- torch.FloatTensor([self.mean_val] ).cuda(args.device),2))
return d

class L_TV(nn.Module):
def __init__(self,TVLoss_weight=1):
super(L_TV,self).__init__()
self.TVLoss_weight = TVLoss_weight

def forward(self,x):
batch_size = x.size()[0]
h_x = x.size()[2]
w_x = x.size()[3]
count_h = (x.size()[2]-1) * x.size()[3]
count_w = x.size()[2] * (x.size()[3] - 1)
h_tv = torch.pow((x[:,:,1:,:]-x[:,:,:h_x-1,:]),2).sum()
w_tv = torch.pow((x[:,:,:,1:]-x[:,:,:,:w_x-1]),2).sum()
return self.TVLoss_weight*2*(h_tv/count_h+w_tv/count_w)/batch_size
class Sa_Loss(nn.Module):
def __init__(self):
super(Sa_Loss, self).__init__()
# print(1)
def forward(self, x ):
# self.grad = np.ones(x.shape,dtype=np.float32)
b,c,h,w = x.shape
# x_de = x.cpu().detach().numpy()
r,g,b = torch.split(x , 1, dim=1)
mean_rgb = torch.mean(x,[2,3],keepdim=True)
mr,mg, mb = torch.split(mean_rgb, 1, dim=1)
Dr = r-mr
Dg = g-mg
Db = b-mb
k =torch.pow( torch.pow(Dr,2) + torch.pow(Db,2) + torch.pow(Dg,2),0.5)
# print(k)


k = torch.mean(k)
return k

class perception_loss(nn.Module):
def __init__(self):
super(perception_loss, self).__init__()
features = vgg16(pretrained=True).features
self.to_relu_1_2 = nn.Sequential()
self.to_relu_2_2 = nn.Sequential()
self.to_relu_3_3 = nn.Sequential()
self.to_relu_4_3 = nn.Sequential()

for x in range(4):
self.to_relu_1_2.add_module(str(x), features[x])
for x in range(4, 9):
self.to_relu_2_2.add_module(str(x), features[x])
for x in range(9, 16):
self.to_relu_3_3.add_module(str(x), features[x])
for x in range(16, 23):
self.to_relu_4_3.add_module(str(x), features[x])

# don't need the gradients, just want the features
for param in self.parameters():
param.requires_grad = False

def forward(self, x):
h = self.to_relu_1_2(x)
h_relu_1_2 = h
h = self.to_relu_2_2(h)
h_relu_2_2 = h
h = self.to_relu_3_3(h)
h_relu_3_3 = h
h = self.to_relu_4_3(h)
h_relu_4_3 = h
# out = (h_relu_1_2, h_relu_2_2, h_relu_3_3, h_relu_4_3)
return h_relu_4_3
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ This is the offical implementation for the paper titled "FusionBooster: A Unifie

[Paper](https://arxiv.org/abs/2305.05970)


## Environment
python 3.7.3
torch 1.9.0
scipy 1.2.0 (important!)

## Test
To use our pre-trained FusionBooster to boost an arbitary IVIF method (e.g., DDcGAN):

```
python test_booster_only.py
```

You can modify the path in the "test_booster_only.py" file, to enhance your own fusion results.

## Announcement
- 2024-10-14 The code for boosting an arbitary method is available ("test_booster_only.py").
- 2024-10-1 Because some of the fusion methods are realised using the tensorflow framework. Our FusionBooster demo will be implemented based on the [MUFusion](https://github.com/AWCXV/MUFusion). You can always use our "detached booster" to enhance your own fusion results.
- 2024-9-30 This work has been accepted by IJCV.

## Highlight
- We devise an image fusion booster by analysing the quality of the initial fusion results by means of a dedicated Information Probe.
- The proposed FusionBooster is a general enhancer, which can be applied to various image fusion methods, e.g., traditional or learning-based algorithms, irrespective of the type of fusion task.
- In a new divide-and-conquer image fusion paradigm, the results of the analysis performed by the Information Probe guide the refinement of the fused image.
- The proposed FusionBooster significantly enhances the performance of the SOTA fusion methods and downstream detection tasks, with only a slight increase in the computational overhead.

The code is coming soon.

## Announcement
- 2024-9-30 This work has been accepted by IJCV.
- 2024-10-1 Because some of the fusion methods are realised using the tensorflow framework. Our FusionBooster demo will be implemented based on the [MUFusion](https://github.com/AWCXV/MUFusion). You can always use our "detached booster" to enhance your own fusion results.
Binary file added __pycache__/Myloss.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/args_fusion.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/args_fusion.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/densefuseNet.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/fusion_strategy.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/fusion_strategy.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/fusion_subNetwork.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/net.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/net.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/net.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/testMat.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/utils.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/utils.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/utils.cpython-38.pyc
Binary file not shown.
40 changes: 40 additions & 0 deletions args_fusion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

class args():

# training args
epochs = 10 #"number of training epochs, default is 2"
batch_size = 2
dataset = "/data/Disk_A/chunyang/codeVFusionE2E/train2014/"
#trainNumber = 26295
trainNumber = 84000
#trainNumber = 40000
HEIGHT = 256
WIDTH = 256
PATCH_SIZE = 128;
PATCH_STRIDE = 4;

save_model_dir = "models" #"path to folder where trained model will be saved."
save_loss_dir = "models/loss" # "path to folder where trained model will be saved."

image_size = 256 #"size of training images, default is 256 X 256"
cuda = 1 #"set it to 1 for running on GPU, 0 for CPU"
seed = 42 #"random seed for training"
ssim_weight = [1,10,100,1000,10000]
ssim_path = ['1e0', '1e1', '1e2', '1e3', '1e4']

lr = 1e-4 #"learning rate, default is 1e-4"
lr_light = 1e-4 # "learning rate, default is 0.001"
log_interval = 2 #"number of images after which the training loss is logged, default is 500"
resume = None
resume_auto_en = None
resume_auto_de = None
resume_auto_fn = None
device = 0;
path = "Epoch_3_iters_3600_";

model_path_gray = "./models/"+path+".model";
#model_path_gray = "stage1.model"
model_path_rgb = "./models/1e2/Epoch_4_iters_400_Sat_Apr_17_10_25_27_2021_1e2.model"



Binary file added dataset/IVT_250/ir/1.png
Binary file added dataset/IVT_250/ir/10.png
Binary file added dataset/IVT_250/ir/100.png
Binary file added dataset/IVT_250/ir/101.png
Binary file added dataset/IVT_250/ir/102.png
Binary file added dataset/IVT_250/ir/103.png
Binary file added dataset/IVT_250/ir/104.png
Loading

0 comments on commit 35de693

Please sign in to comment.