CaptainEven / VideoCaption

视频的文本摘要(标注),输入一段视频,通过深度学习网络和人工智能程序识别视频主要表达的意思(Input a video output a txt decribing the video)。
179 stars 54 forks source link

怎么解决这个问题,多谢!先感谢分享 #7

Open joyzyyz opened 4 years ago

joyzyyz commented 4 years ago

(base) D:\F\VideoCaption19>python videoCaption.py video10034.mp4 in_file: video10034.mp4 IMG_SIZE: (256, 192) --processing video... 18%|█████████████████████████████████▋ | 40%|████████████████████████████████████████████████████████████████████████▊ 62%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ 84%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████| 527/527 [00:00<00:00, 1125.99it/s]

--processing key frames... 0%| | 0/15 [00:00<?, ?it/s]D :\F\VideoCaption19\img2txt.py:99: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. img_feats = feat_extractor(Variable(img, volatile=True)) D:\F\VideoCaption19\model.py:60: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. img = t.autograd.Variable(img.unsqueeze(0), volatile=True) D:\F\VideoCaption19\utils\beam_search.py:156: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument. logprobs = log_softmax(output) D:\F\VideoCaption19\utils\beam_search.py:180: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. input_feed = Variable(input_feed, volatile=True) 0%| | 0/15 [00:00<?, ?it/s] Traceback (most recent call last): File "videoCaption.py", line 121, in video2txt(in_file) File "videoCaption.py", line 73, in video2txt txts += generate_txt(img, tr4s, resnet50, cap_model, opt.use_gpu) File "D:\F\VideoCaption19\img2txt.py", line 105, in generate_txt results = model.generate(img_feats.data[0]) File "D:\F\VideoCaption19\model.py", line 64, in generate for sent in sentences] File "D:\F\VideoCaption19\model.py", line 64, in for sent in sentences] File "D:\F\VideoCaption19\model.py", line 63, in sentences = [' '.join([self.ix2word[idx] for idx in sent]) KeyError: tensor(51)

zhuchiheng commented 3 years ago

(base) D:\F\VideoCaption19>python videoCaption.py video10034.mp4 in_file: video10034.mp4 IMG_SIZE: (256, 192) --processing video... 18%|█████████████████████████████████▋ | 40%|████████████████████████████████████████████████████████████████████████▊ 62%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ 84%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████████████████████| 527/527 [00:00<00:00, 1125.99it/s]

--processing key frames... 0%| | 0/15 [00:00<?, ?it/s]D :\F\VideoCaption19\img2txt.py:99: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. img_feats = feat_extractor(Variable(img, volatile=True)) D:\F\VideoCaption19\model.py:60: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. img = t.autograd.Variable(img.unsqueeze(0), volatile=True) D:\F\VideoCaption19\utils\beam_search.py:156: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument. logprobs = log_softmax(output) D:\F\VideoCaption19\utils\beam_search.py:180: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. input_feed = Variable(input_feed, volatile=True) 0%| | 0/15 [00:00<?, ?it/s] Traceback (most recent call last): File "videoCaption.py", line 121, in video2txt(in_file) File "videoCaption.py", line 73, in video2txt txts += generate_txt(img, tr4s, resnet50, cap_model, opt.use_gpu) File "D:\F\VideoCaption19\img2txt.py", line 105, in generate_txt results = model.generate(img_feats.data[0]) File "D:\F\VideoCaption19\model.py", line 64, in generate for sent in sentences] File "D:\F\VideoCaption19\model.py", line 64, in for sent in sentences] File "D:\F\VideoCaption19\model.py", line 63, in sentences = [' '.join([self.ix2word[idx] for idx in sent]) KeyError: tensor(51)

@joyzyyz 改为: sentences = [' '.join([self.ix2word[idx.item()] for idx in sent])