FatBoyEnglish
commited on
Update app.py
Browse files
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 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|