File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change
1
+ .DS_Store
2
+ * .pth
3
+ * .pyc
4
+ * .pyo
5
+ * .log
6
+ * .tmp
7
+
Original file line number Diff line number Diff line change 11
11
img_path = './data/demo.png'
12
12
alphabet = '0123456789abcdefghijklmnopqrstuvwxyz'
13
13
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 ()
15
17
print ('loading pretrained model from %s' % model_path )
16
18
model .load_state_dict (torch .load (model_path ))
17
19
18
20
converter = utils .strLabelConverter (alphabet )
19
21
20
22
transformer = dataset .resizeNormalize ((100 , 32 ))
21
23
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 ()
23
27
image = image .view (1 , * image .size ())
24
28
image = Variable (image )
25
29
You can’t perform that action at this time.
0 commit comments