FatBoyEnglish commited on
Commit
e0cd865
·
verified ·
1 Parent(s): 5faf260

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -44,14 +44,23 @@ def initialize_model(model_file):
44
  return transform,ort_session
45
 
46
  def get_text(img_org):
47
- x = transform(img_org.convert('RGB')).unsqueeze(0)
48
- ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
49
- logits = ort_session.run(None, ort_inputs)[0]
50
- probs = torch.tensor(logits).softmax(-1)
51
- preds, _ = tokenizer_base.decode(probs)
52
- preds = preds[0]
53
- print(preds)
54
- return preds
 
 
 
 
 
 
 
 
 
55
 
56
  transform,ort_session = initialize_model(model_file=model_file)
57
 
 
44
  return transform,ort_session
45
 
46
  def get_text(img_org):
47
+ try:
48
+ print("debugger1")
49
+ x = transform(img_org.convert('RGB')).unsqueeze(0)
50
+ print("debugger2")
51
+ ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
52
+ print("debugger3")
53
+ logits = ort_session.run(None, ort_inputs)[0]
54
+ print("debugger4")
55
+ probs = torch.tensor(logits).softmax(-1)
56
+ print("debugger5")
57
+ preds, _ = tokenizer_base.decode(probs)
58
+ print("debugger6")
59
+ preds = preds[0]
60
+ print(preds)
61
+ return preds
62
+ except Exception as e:
63
+ print(str(e))
64
 
65
  transform,ort_session = initialize_model(model_file=model_file)
66