#!/usr/bin/env python # -*- coding: utf-8 -*- """ @project: @File : temple_part @Author : qiqq @create_time : 2023/5/22 22:38 """ import torch from torch import nn import torch.nn.functional as F import numpy as np import math # class upmodel(nn.Module): # # def __init__(self, # in_channels, # out_channels, # in_feat_output_strides=(4, 8, 16, 32), # out_feat_output_stride=4, # ): # super(upmodel, self).__init__() # self.blocks = nn.ModuleList() # for in_feat_os in in_feat_output_strides: # num_upsample = int(math.log2(int(in_feat_os))) - int(math.log2(int(out_feat_output_stride))) # # num_layers = num_upsample if num_upsample != 0 else 1 # # self.blocks.append(nn.Sequential(*[ # nn.Sequential( # nn.Conv2d(in_channels if idx == 0 else out_channels, out_channels, 3, 1, 1, bias=False), # nn.BatchNorm2d(out_channels), # nn.ReLU(inplace=True), # nn.UpsamplingBilinear2d(scale_factor=2) if num_upsample != 0 else nn.Identity(), # ) # for idx in range(num_layers)])) # # def forward(self, feat_list: list): # inner_feat_list = [] # for idx, block in enumerate(self.blocks): # decoder_feat = block(feat_list[idx]) # inner_feat_list.append(decoder_feat) # # out_feat = sum(inner_feat_list) / 4. #待定 # return out_feat # # # impo1=torch.rand(1,64,128,128) # impo2=torch.rand(1,256,64,64) # impo1=torch.rand(1,512,32,32) # impo1=torch.rand(1,768,16,16) # # lis=[torch.rand(1,64,128,128), # torch.rand(1,256,64,64), # torch.rand(1,512,32,32), # torch.rand(1,768,16,16) # ] # # model=upmodel()