Tennineee commited on
Commit
d607a5c
·
verified ·
1 Parent(s): 531ca1b

Update models/PDFNet.py

Browse files
Files changed (1) hide show
  1. models/PDFNet.py +0 -67
models/PDFNet.py CHANGED
@@ -61,26 +61,6 @@ class PDF_depth_decoder(nn.Module):
61
 
62
  return [final_output,side_1,side_2,side_3,side_4]
63
 
64
- class CoA(nn.Module):
65
- def __init__(self, emb_dim=128):
66
- super(CoA, self).__init__()
67
- self.Att = nn.MultiheadAttention(emb_dim,1,bias=False,batch_first=True,dropout=0.1)
68
- self.Normq = RMSNorm(emb_dim,data_format='channels_last')
69
- self.Normkv = RMSNorm(emb_dim,data_format='channels_last')
70
- self.drop1 = nn.Dropout(0.1)
71
- self.FFN = SwiGLU(emb_dim,emb_dim)
72
- self.Norm2 = RMSNorm(emb_dim,data_format='channels_last')
73
- self.drop2 = nn.Dropout(0.1)
74
-
75
- def forward(self,q,kv):
76
- res = q
77
- KV_feature = self.Att(self.Normq(q), self.Normkv(kv), self.Normkv(kv))[0]
78
- KV_feature = self.drop1(KV_feature) + res
79
- res = KV_feature
80
- KV_feature = self.FFN(self.Norm2(KV_feature))
81
- KV_feature = self.drop2(KV_feature) + res
82
- return KV_feature
83
-
84
  class CoA(nn.Module):
85
  def __init__(self, emb_dim=128):
86
  super(CoA, self).__init__()
@@ -223,53 +203,6 @@ class FSE(nn.Module):
223
 
224
  return img_feature + rearrange(img_cs, 'b (h w) c -> b c h w',h=img_H), depth_feature + depth_cs, patch_feature + patch_cs
225
 
226
- # def forward(self,img,depth,patch,last_pred):
227
- # boundary,integrity = self.BIS(last_pred)
228
- # # img = img * _upsample_like(last_pred.sigmoid(),img)
229
- # # depth = depth * _upsample_like(last_pred.sigmoid(),depth)
230
- # # patch = patch * _upsample_like(last_pred.sigmoid(),patch)
231
- # pi,pd,pp = self.pool_ratio
232
- # B,C,img_H,img_W = img.size()
233
- # img_cs = self.I_channelswich(img* (1+_upsample_like(integrity,depth)))
234
- # pool_img_cs = F.adaptive_avg_pool2d(img_cs,output_size=[img_H//pi,img_W//pi])
235
- # # img_cs = rearrange(img_cs, 'b c h w -> b (h w) c')
236
- # pool_img_cs = rearrange(pool_img_cs, 'b c h w -> b (h w) c')
237
- # B,C,depth_H,depth_W = depth.size()
238
-
239
- # #give depth the integrity prior
240
- # enhance_depth = depth * _upsample_like(last_pred.sigmoid(),depth)
241
- # depth_cs = self.D_channelswich(enhance_depth)
242
- # pool_depth_cs = F.adaptive_avg_pool2d(depth_cs,output_size=[depth_H//pd,depth_W//pd])
243
- # depth_cs = rearrange(depth_cs, 'b c h w -> b (h w) c')
244
- # pool_depth_cs = rearrange(pool_depth_cs, 'b c h w -> b (h w) c')
245
- # B,C,patch_H,patch_W = patch.size()
246
-
247
- # #select the boundary patches to select patches
248
- # patch_batch = self.split(patch,patch_ratio=self.patch_ratio)
249
- # boundary_batch = self.split(boundary,patch_ratio=self.patch_ratio)
250
- # boundary_score = boundary_batch.mean(dim=[2,3])[...,None,None]
251
- # select_patch = patch_batch * (1+(boundary_score>0).float())
252
- # select_patch = self.merge(select_patch,batch_size=B)
253
-
254
- # patch_cs = self.P_channelswich(select_patch)
255
- # pool_patch_cs = F.adaptive_avg_pool2d(patch_cs,output_size=[patch_H//pp,patch_W//pp])
256
- # pool_patch_cs = rearrange(pool_patch_cs, 'b c h w -> b (h w) c')
257
-
258
- # patch_feature = self.PI(pool_patch_cs, torch.cat([pool_img_cs,pool_depth_cs],dim=1))
259
- # depth_feature = self.IP(depth_cs,patch_feature)
260
-
261
- # img_feature = self.DI(pool_img_cs, torch.cat([pool_img_cs,pool_patch_cs],dim=1))
262
- # depth_feature = self.ID(depth_feature,img_feature)
263
-
264
- # patch_feature = rearrange(patch_feature, 'b (h w) c -> b c h w',h=patch_H//pp)
265
- # depth_feature = rearrange(depth_feature, 'b (h w) c -> b c h w',h=depth_H)
266
- # img_feature = rearrange(img_feature, 'b (h w) c -> b c h w',h=img_H//pi)
267
-
268
- # img_feature = _upsample_like(img_feature,img)
269
- # patch_feature = _upsample_like(patch_feature,patch)
270
-
271
- # return img_feature + img_cs, depth_feature + rearrange(depth_cs, 'b (h w) c -> b c h w',h=depth_H), patch_feature + patch_cs
272
-
273
  class PDF_decoder(nn.Module):
274
  def __init__(self, args,raw_ch=3,out_ch=1):
275
  super(PDF_decoder, self).__init__()
 
61
 
62
  return [final_output,side_1,side_2,side_3,side_4]
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  class CoA(nn.Module):
65
  def __init__(self, emb_dim=128):
66
  super(CoA, self).__init__()
 
203
 
204
  return img_feature + rearrange(img_cs, 'b (h w) c -> b c h w',h=img_H), depth_feature + depth_cs, patch_feature + patch_cs
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  class PDF_decoder(nn.Module):
207
  def __init__(self, args,raw_ch=3,out_ch=1):
208
  super(PDF_decoder, self).__init__()