,amazon-web-services"/>

首页 > 解决方案 > 模块初始化错误:

问题描述

在 lambda 函数中执行测试配置时我面临此错误模块初始化错误:<urlopen 错误 [Errno 110] 连接超时>

我在使用torch.hub.load. 请帮我弄清楚这个问题。谢谢。

import torch
import numpy as np
import urllib
print(np.__version__);print(np.__file__)
#from scipy.io.wavfile import write
from os import path
print(torch.__version__)
print(torch.cuda.is_available())

waveglow_path = torch.hub.load('nvidia/DeepLearningExamples:torchhub', 
'nvidia_waveglow')

waveglow = waveglow_path.to('cuda')
waveglow.eval()
#waveglow.cpu().eval()

import boto3



 bucket = 'ttsmodel'
 key= 'TTS_Nigerian'
 dest_file = '/tmp/'




  model_path = dest_file
  #def load_model():
  #model_path = get_model()
  #tacotron2 = torch.hub.load('nvidia/DeepLearningExamples:torchhub', 
 'nvidia_tacotron2')
  #tacotron2.load_state_dict(torch.load(model_path)['state_dict'])
  #tacotron2 = tacotron2.to('cuda')
  #tacotron2.eval()

   #return tacotron2
   tmp_file_path = "\tmp\TTS_Nigerian"

   def lambda_handler(event, context):

   s3 = boto3.resource('s3')
   s3.Bucket(bucket).download_file(key, dest_file)

   #os.path.isfile('/tmp/' + filename)
  
   model_path= dest_file
    tacotron2 = torch.hub.load('nvidia/DeepLearningExamples:torchhub', 
     'nvidia_tacotron2')
     tacotron2.load_state_dict(torch.load(model_path)['state_dict'])
     tacotron2 = tacotron2.to('cuda')
     tacotron2.eval()
     #s3 = boto3.resource('s3')
     #with open('TTS_Nigerian', wb) as tacotron2:
      #s3.Bucket(bucket).download_file(key, tacotron2)          
      #tacotron2 = load_model()
       text = "Dear User, Your guider got closed unexpectedly.Would you 
   like to continue from where you left off."

    utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 
    'nvidia_tts_utils')
    sequence, lengths = utils.prepare_input_sequence([text])




     with torch.no_grad():

    mel_output_postnet, _, alignment = tacotron2.infer(sequence, lengths)
    audio = waveglow.infer(mel_output_postnet)

    #plot_data((mel_output_postnet.float().data.cpu().numpy()[0],
                #alignment.float().data.cpu().numpy()[0].T))
audio_numpy = audio[0].data.cpu().numpy()
sampling_rate = 22050

from IPython.display import Audio
Audio(audio_numpy, rate=sampling_rate)

标签: amazon-web-services

解决方案


推荐阅读