本文共 1466 字,大约阅读时间需要 4 分钟。
????????ResNet50?????????????????????????????????????????????????????????????PyTorch??????ResNet50???????????????
ResNet50??????????????????????Residual Blocks??????????????????
??? inference ??????????????????PyTorch?????????????????????????????????????
??????????????????
import cv2import timeimport osimport matplotlib.pyplot as pltimport torchfrom torch import nnimport torchvision.models as modelsimport torchvision.transforms as transformssavepath = 'vis_resnet50/features_elephant'if not os.path.exists(savepath): os.mkdir(savepath)def draw_features(width, height, x, savename): tic = time.time() fig = plt.figure(figsize=(16, 16)) fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95, wspace=0.05) # ?????????? plt.imshow(x) plt.savefig(os.path.join(savepath, savename)) plt.close() toc = time.time() print(f"?????{toc - tic:.2f}?") ????????????????ResNet50??????????????????????????
转载地址:http://taxz.baihongyu.com/