-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_implicit.py
42 lines (34 loc) · 1.16 KB
/
get_implicit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: UTF-8 -*-
"""
@Author: mpj
@Date : 2024/3/24 15:26
@version V1.0
"""
import os
import torch
import matplotlib.pyplot as plt
# 设置字体为times new roman
plt.rcParams['font.family'] = 'Times New Roman'
origin_model_path = './runs-experiment/train/v9-c-double-implicitConvCBFuse/weights/best.pt'
###########
index = 36
device = torch.device("cpu")
ckpt = torch.load(origin_model_path, map_location='cpu')
model = ckpt['model']
m = model.model[index]
###################
v = m.ia.implicit.numpy().squeeze()
# v = m.im.implicit.numpy().squeeze()
v = list(v)
# 横坐标是从0到v的长度,纵坐标是v的值
# plt.bar(range(len(v) + 60), v + [0] * 60)
plt.figure(figsize=(4, 3))
plt.bar(range(len(v)), v)
# plt.xlabel('index')
# plt.ylabel('value')
# plt.title('implicitA-' + str(index))
plt.savefig('implicit_ia_{}.png'.format(index), transparent=True, bbox_inches='tight', pad_inches=0.0, dpi=600)
# plt.savefig('implicit_im_{}.png'.format(index), transparent=True, bbox_inches='tight', pad_inches=0.0, dpi=600)
# with open('implicit_ia_{}.csv'.format(index), 'w') as f:
# for i, item in enumerate(v):
# f.write(str(i) + ',' + str(item) + '\n')