Tayaba171 commited on
Commit
611b927
1 Parent(s): b6a4fbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -37
app.py CHANGED
@@ -27,43 +27,6 @@ os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
27
 
28
 
29
 
30
- def load_dict_picklefile(dictFile):
31
- fp=open(dictFile,'rb')
32
- lexicon=pkl.load(fp)
33
- fp.close()
34
- return lexicon,lexicon[' ']
35
-
36
- def preprocess_img(img):
37
- if len(img.shape)>2:
38
- img= cv2.cvtColor(img.astype('float32'), cv2.COLOR_BGR2GRAY)
39
- height=img.shape[0]
40
- width=img.shape[1]
41
-
42
- if(width<300):
43
- result = np.ones([img.shape[0], img.shape[1]*2])*255
44
- result[0:img.shape[0],img.shape[1]:img.shape[1]*2]=img
45
- img=result
46
-
47
- img=cv2.resize(img, dsize=(800,100), interpolation = cv2.INTER_AREA)
48
- img=(img-img.min())/(img.max()-img.min())
49
- xx_pad = np.zeros((100, 800), dtype='float32')
50
- xx_pad[:,:] =1
51
-
52
- xx_pad = xx_pad[None, :, :]
53
- img=img[None, :, :]
54
- return img, xx_pad
55
-
56
-
57
- worddicts,_ = load_dict_picklefile('vocabulary.pkl')
58
- worddicts_r = [None] * len(worddicts)
59
- i=1
60
- for kk, vv in worddicts.items():
61
- if(i<len(worddicts)):
62
- worddicts_r[vv] = kk
63
- else:
64
- break
65
- i=i+1
66
-
67
  # Create an instance of the model
68
  CALTEXT = CALTextModel.CALTEXT_Model(training=False)
69
  CALTEXT.load_weights('final_caltextModel/cp-0037.ckpt')
 
27
 
28
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  # Create an instance of the model
31
  CALTEXT = CALTextModel.CALTEXT_Model(training=False)
32
  CALTEXT.load_weights('final_caltextModel/cp-0037.ckpt')