Skip to content

Commit 1b95b89

Browse files
authored
Merge pull request meijieru#45 from ZhangXinNan/zxdev
add .gitignore, add "if torch.cuda.is_available():" in demo.py
2 parents 4850b73 + fd26e80 commit 1b95b89

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
*.pth
3+
*.pyc
4+
*.pyo
5+
*.log
6+
*.tmp
7+

demo.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
img_path = './data/demo.png'
1212
alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'
1313

14-
model = crnn.CRNN(32, 1, 37, 256).cuda()
14+
model = crnn.CRNN(32, 1, 37, 256)
15+
if torch.cuda.is_available():
16+
model = model.cuda()
1517
print('loading pretrained model from %s' % model_path)
1618
model.load_state_dict(torch.load(model_path))
1719

1820
converter = utils.strLabelConverter(alphabet)
1921

2022
transformer = dataset.resizeNormalize((100, 32))
2123
image = Image.open(img_path).convert('L')
22-
image = transformer(image).cuda()
24+
image = transformer(image)
25+
if torch.cuda.is_available():
26+
image = image.cuda()
2327
image = image.view(1, *image.size())
2428
image = Variable(image)
2529

0 commit comments

Comments
 (0)