Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
joyzyyz opened this issue May 20, 2020 · 1 comment
Open

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

joyzyyz opened this issue May 20, 2020 · 1 comment

Comments

@joyzyyz
Copy link

joyzyyz commented May 20, 2020

(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
Copy link

zhuchiheng commented Jan 31, 2021

(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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants