File size: 569 Bytes
728ab38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from bart import BartCaptionModel
from audio_utils import load_audio, STR_CH_FIRST
import torch

try:
    device = "cuda:0" if torch.cuda.is_available() else "cpu"
except:
    print("1")
try:
    model = BartCaptionModel(max_length = 128)
except:
    print("2")

try:
    pretrained_object = torch.load('transfer.pth', map_location='cpu')
except:
    print("3")

try:
    state_dict = pretrained_object['state_dict']
except:
    print("4")

try:
    model.load_state_dict(state_dict)
except:
    print("5")

try:
    torch.save(model,"model.pth")
except:
    print("6")