Tanaanan commited on
Commit
debedb8
·
1 Parent(s): 160472f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +492 -0
app.py ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st #Web App
2
+ from PIL import Image, ImageOps #Image Processing
3
+ import time
4
+ from unittest import result
5
+ import numpy as np
6
+ from icevision.all import *
7
+ from icevision.models.checkpoint import *
8
+ import easyocr as ocr #OCR
9
+ import editdistance
10
+
11
+
12
+ st.sidebar.image("./logo.png")
13
+ st.sidebar.header("ATK-OCR classification (AOC) Webapp.")
14
+ def load_image(image_file):
15
+ img = Image.open(image_file)
16
+ return img
17
+
18
+
19
+ activities = ["Detection", "About"]
20
+ choice = st.sidebar.selectbox("Select option..",activities)
21
+
22
+ #set default size as 1280 x 1280
23
+ def img_resize(input_path,img_size): # padding
24
+ desired_size = img_size
25
+ im = Image.open(input_path)
26
+ im = ImageOps.exif_transpose(im) # fix image rotating
27
+ width, height = im.size # get img_input size
28
+ if (width == 1280) and (height == 1280):
29
+ new_im = im
30
+ else:
31
+ #im = im.convert('L') #Convert to gray
32
+ old_size = im.size # old_size[0] is in (width, height) format
33
+ ratio = float(desired_size)/max(old_size)
34
+ new_size = tuple([int(x*ratio) for x in old_size])
35
+ im = im.resize(new_size, Image.ANTIALIAS)
36
+ new_im = Image.new("RGB", (desired_size, desired_size))
37
+ new_im.paste(im, ((desired_size-new_size[0])//2,
38
+ (desired_size-new_size[1])//2))
39
+
40
+ return new_im
41
+
42
+ checkpoint_path = "./AOC_weight_97.4.pth"
43
+
44
+ checkpoint_and_model = model_from_checkpoint(checkpoint_path,
45
+ model_name='ross.efficientdet',
46
+ backbone_name='tf_d2',
47
+ img_size=384,
48
+ is_coco=False)
49
+
50
+ model_type = checkpoint_and_model["model_type"]
51
+ backbone = checkpoint_and_model["backbone"]
52
+ class_map = checkpoint_and_model["class_map"]
53
+ img_size = checkpoint_and_model["img_size"]
54
+ #model_type, backbone, class_map, img_size
55
+
56
+ model = checkpoint_and_model["model"]
57
+
58
+ device=next(model.parameters()).device
59
+
60
+ img_size = checkpoint_and_model["img_size"]
61
+ valid_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(img_size), tfms.A.Normalize()])
62
+
63
+ def get_detection(img_path):
64
+
65
+ #Get_Idcard_detail(file_path=img_path)
66
+ img = Image.open(img_path)
67
+ img = ImageOps.exif_transpose(img) # fix image rotating
68
+ width, height = img.size # get img_input size
69
+ if (width == 1280) and (height == 1280):
70
+ pred_dict = model_type.end2end_detect(img, valid_tfms, model, class_map=class_map, detection_threshold=0.6)
71
+ else:
72
+ #im = im.convert('L') #Convert to gray
73
+ old_size = img.size # old_size[0] is in (width, height) format
74
+ ratio = float(1280)/max(old_size)
75
+ new_size = tuple([int(x*ratio) for x in old_size])
76
+ img = img.resize(new_size, Image.ANTIALIAS)
77
+ new_im = Image.new("RGB", (1280, 1280))
78
+ new_im.paste(img, ((1280-new_size[0])//2,
79
+ (1280-new_size[1])//2))
80
+ pred_dict = model_type.end2end_detect(new_im, valid_tfms, model, class_map=class_map, detection_threshold=0.6)
81
+
82
+
83
+
84
+ #st.write(new_im.size)
85
+
86
+
87
+
88
+ try:
89
+ labels, acc = pred_dict['detection']['labels'][0], pred_dict['detection']['scores'][0]
90
+ acc = acc * 100
91
+ if labels == "Neg":
92
+ labels = "Negative"
93
+ elif labels == "Pos":
94
+ labels = "Positive"
95
+ st.success(f"Result : {labels} with {round(acc, 2)}% confidence.")
96
+ except IndexError:
97
+ st.error("Not found ATK image! ; try to take image again..")
98
+ labels = "None"
99
+ acc = 0
100
+
101
+ def get_img_detection(img_path):
102
+
103
+ #Get_Idcard_detail(file_path=img_path)
104
+ img = Image.open(img_path)
105
+ img = ImageOps.exif_transpose(img) # fix image rotating
106
+ width, height = img.size # get img_input size
107
+ if (width == 1280) and (height == 1280):
108
+ new_im = img
109
+ else:
110
+ #im = im.convert('L') #Convert to gray
111
+ old_size = img.size # old_size[0] is in (width, height) format
112
+ ratio = float(1280)/max(old_size)
113
+ new_size = tuple([int(x*ratio) for x in old_size])
114
+ img = img.resize(new_size, Image.ANTIALIAS)
115
+ new_im = Image.new("RGB", (1280, 1280))
116
+ new_im.paste(img, ((1280-new_size[0])//2,
117
+ (1280-new_size[1])//2))
118
+
119
+ pred_dict = model_type.end2end_detect(new_im, valid_tfms, model, class_map=class_map, detection_threshold=0.6)
120
+
121
+
122
+ return pred_dict['img']
123
+
124
+ def load_model():
125
+ reader = ocr.Reader(['en'],model_storage_directory='.')
126
+ return reader
127
+
128
+ reader = load_model() #load model
129
+
130
+ def Get_Idcard_detail(file_path):
131
+ raw_data = []
132
+ id_num = {"id_num" : "None"}
133
+ name = file_path
134
+ img = Image.open(name)
135
+ img = ImageOps.exif_transpose(img) # fix image rotating
136
+
137
+ width, height = img.size # get img_input size
138
+ if (width == 1280) and (height == 1280):
139
+ result = reader.readtext(np.array(img))
140
+ else:
141
+ #im = im.convert('L') #Convert to gray
142
+ old_size = img.size # old_size[0] is in (width, height) format
143
+ ratio = float(1280)/max(old_size)
144
+ new_size = tuple([int(x*ratio) for x in old_size])
145
+ img = img.resize(new_size, Image.ANTIALIAS)
146
+ new_im = Image.new("RGB", (1280, 1280))
147
+ new_im.paste(img, ((1280-new_size[0])//2,
148
+ (1280-new_size[1])//2))
149
+
150
+ result = reader.readtext(np.array(new_im))
151
+
152
+
153
+
154
+
155
+ result_text = [] #empty list for results
156
+ for text in result:
157
+ result_text.append(text[1])
158
+
159
+
160
+ raw_data = result_text
161
+
162
+
163
+ def Clear_syntax(raw_list):
164
+
165
+ Clean_syntax = ["","#","{","}","=","/","@","#","$","—","|","%","-","(",")","¥", "[", "]", "‘",':',';']
166
+
167
+ for k in range(len(Clean_syntax)):
168
+ while (Clean_syntax[k] in raw_list): # remove single symbol
169
+ raw_list.remove(Clean_syntax[k])
170
+
171
+ for l in range(len(raw_list)):
172
+ raw_list[l] = raw_list[l].replace("!","l") #split ! --> l (Error OCR Check)
173
+ raw_list[l] = raw_list[l].replace(",",".") #split ! --> l (Error OCR Check)
174
+ raw_list[l] = raw_list[l].replace(" ","") #split " " out from str
175
+ raw_list[l] = raw_list[l].lower() #Set all string to lowercase
176
+
177
+ for m in range(len(raw_list)): #Clear symbol in str "Hi/'" --> "Hi"
178
+ for n in range(len(Clean_syntax)):
179
+ raw_list[m] = raw_list[m].replace(Clean_syntax[n],"")
180
+ return raw_list
181
+
182
+ raw_data = Clear_syntax(raw_data)
183
+
184
+
185
+ def get_idnum(raw_list):
186
+ id_num = {"id_num" : "None"}
187
+ # 1. normal check
188
+ for i in range(len(raw_list)): # check if len(list) = 1, 4, 5, 2, 1 (13 digit idcard) and all is int
189
+ try:
190
+ if ((len(raw_list[i]) == 1) and (len(raw_list[i+1]) == 4) and (len(raw_list[i+2]) == 5) and (len(raw_list[i+3]) == 2) and (len(raw_list[i+4]) == 1)) and ((raw_list[i] + raw_list[i+1] + raw_list[i+2] + raw_list[i+3] + raw_list[i+4]).isnumeric()):
191
+ id_num["id_num"] = (raw_list[i] + raw_list[i+1] + raw_list[i+2] + raw_list[i+3] + raw_list[i+4])
192
+ break
193
+ except:
194
+ pass
195
+
196
+ # 2. Hardcore Check
197
+ if id_num["id_num"] == "None":
198
+ id_count = 0
199
+ index_first = 0
200
+ index_end = 0
201
+ for i in range(len(raw_list)):
202
+ if id_count == 13:
203
+ index_end = i-1 #ลบ 1 index เพราะ ครบ 13 รอบก่อนหน้านี้
204
+ #print(f"index_first == {index_first} index_end == {index_end}")
205
+ #print(f"id = {raw_list[index_first:index_end+1]}")
206
+ id_num["id_num"] = ''.join(raw_list[index_first:index_end+1])
207
+ break
208
+ else:
209
+ if raw_list[i].isnumeric() == True and index_first == 0:
210
+ id_count += len(raw_list[i])
211
+ index_first = i
212
+ elif raw_list[i].isnumeric() == True and index_first != 0:
213
+ id_count += len(raw_list[i])
214
+ elif raw_list[i].isnumeric() == False:
215
+ id_count = 0
216
+ index_first = 0
217
+
218
+ return id_num
219
+
220
+ id_num = (get_idnum(raw_data))
221
+
222
+ #Complete list name check
223
+ def list_name_check(raw_list):
224
+ sum_list = raw_list
225
+ name_key = ['name', 'lastname']
226
+
227
+ #1. name_key check
228
+ if ("name" in sum_list) and ("lastname" in sum_list): # if name and lastname in list pass it!
229
+ pass
230
+ else:
231
+ for i in range(len(name_key)):
232
+ for j in range(len(sum_list)):
233
+ if (editdistance.eval(name_key[i], sum_list[j]) <= 2 ):
234
+ sum_list[j] = name_key[i]
235
+
236
+ gender_key = ["mr.", "mrs.", 'master', 'miss']
237
+ #2 gender_key check
238
+ count = 0 # check for break
239
+ for i in range(len(gender_key)):
240
+ for j in range(len(sum_list)):
241
+ if (count == 0):
242
+ try:
243
+ if (sum_list[i] == "name") or (sum_list[i] == "lastname"): # skip "name" and "lastname"
244
+ pass
245
+ else:
246
+ # mr, mrs sensitive case double check with len(gender_key) == len(keyword)
247
+ if (gender_key[i] == "mr." or gender_key[i] == "mrs.") and (editdistance.eval(gender_key[i], sum_list[j]) <= 3 and (len(gender_key[i]) == len(sum_list[j]))):
248
+ sum_list[j] = gender_key[i]
249
+ count+=1
250
+ #print(1)
251
+ elif (gender_key[i] == "master" or gender_key[i] == "miss") and (editdistance.eval(gender_key[i], sum_list[j]) <= 3 ) and (len(gender_key[i]) == len(sum_list[j])):
252
+ sum_list[j] = gender_key[i]
253
+ count+=1
254
+ #print(1)
255
+ except:
256
+ if (gender_key[i] == "mr." or gender_key[i] == "mrs.") and (editdistance.eval(gender_key[i], sum_list[j]) <= 2 and (len(gender_key[i]) == len(sum_list[j]))):
257
+ sum_list[j] = gender_key[i]
258
+ count+=1
259
+ #print(1)
260
+ elif (gender_key[i] == "master" or gender_key[i] == "miss") and (editdistance.eval(gender_key[i], sum_list[j]) <= 3 ) and (len(gender_key[i]) == len(sum_list[j])):
261
+ sum_list[j] = gender_key[i]
262
+ count+=1
263
+ #print(1)
264
+ else:
265
+ break
266
+
267
+ return sum_list
268
+
269
+ raw_data = list_name_check(raw_data)
270
+
271
+ #get_eng_name
272
+ def get_engname(raw_list):
273
+ get_data = raw_list
274
+ engname_list = []
275
+
276
+ name_pos = []
277
+ lastname_pos = []
278
+ mr_pos = []
279
+ mrs_pos = []
280
+
281
+ # check keyword by name, lastname, master, mr, miss, mrs
282
+ for j in range(len(get_data)): #get "name" , "lastname" index
283
+ if "name" == get_data[j]:
284
+ name_pos.append(j)
285
+ elif "lastname" == get_data[j]:
286
+ lastname_pos.append(j)
287
+ elif ("mr." == get_data[j]) or ("master" == get_data[j]):
288
+ mr_pos.append(j)
289
+ elif ("miss" == get_data[j]) or ("mrs." == get_data[j]):
290
+ mrs_pos.append(j)
291
+
292
+
293
+ if len(name_pos) != 0: #get_engname ex --> ['name', 'master', 'tanaanan', 'lastname', 'chalermpan']
294
+ engname_list = get_data[name_pos[0]:name_pos[0]+6] # select first index กรณีมี "name" มากกว่า 1 ตัว
295
+ elif len(lastname_pos) != 0:
296
+ engname_list = get_data[lastname_pos[0]-3:lastname_pos[0]+3]
297
+ elif len(mr_pos) != 0:
298
+ engname_list = get_data[mr_pos[0]-1:mr_pos[0]+5]
299
+ elif len(mrs_pos) != 0:
300
+ engname_list = get_data[mrs_pos[0]-1:mrs_pos[0]+5]
301
+ else:
302
+ print("Can't find eng name!!")
303
+
304
+ return engname_list
305
+
306
+ raw_data = get_engname(raw_data)
307
+
308
+
309
+
310
+
311
+ def split_genkey(raw_list): # remove stringname + gender_key ex. "missjate" -> "jate"
312
+ data = raw_list
313
+ key = ['mrs.','mr.','master','miss']
314
+ name = "" #gen_key name
315
+ name_pos = 0
316
+ gen_index = 0
317
+ gen_type = "" #male / female
318
+ # check keyword
319
+ for key_val in key:
320
+ for each_text in data:
321
+ if (each_text[:len(key_val)] == key_val) or (editdistance.eval(each_text[:len(key_val)],key_val) <= 1 and (len(each_text[:len(key_val)]) == len(key_val))):
322
+ #each_text = each_text[len(key):]
323
+ if (each_text == "name") or (each_text == "lastname"):
324
+ pass
325
+ else:
326
+ name = (each_text[:len(key_val)])
327
+ name_pos = data.index(each_text) # get_index
328
+ gen_index = len(key_val)
329
+ break
330
+ if (name_pos != 0):
331
+ data[name_pos] = data[name_pos][gen_index:] # split gender_key on list
332
+ for empty_str in range(data.count('')): # clear "empty string"
333
+ data.remove('')
334
+ return data
335
+
336
+ raw_data = split_genkey(raw_data)
337
+
338
+
339
+ def clean_name_data(raw_list): # delete all single string and int string
340
+ for k in range(len(raw_list)):
341
+ try:
342
+ while ((len(raw_list[k]) <= 2) or (raw_list[k].isnumeric() == True)): # remove single symbol
343
+ raw_list.remove(raw_list[k])
344
+ except IndexError:
345
+ pass
346
+ return raw_list
347
+
348
+ raw_data = clean_name_data(raw_data)
349
+
350
+
351
+ def name_sum(raw_list):
352
+ info = {"name" : "None",
353
+ "lastname" : "None"}
354
+ key = ['mr.','mrs.', 'master', 'miss', 'mrs','mr']
355
+ name_pos = 0
356
+ lastname_pos = 0
357
+ for key_val in key: # remove gender_key in string
358
+ if key_val in raw_list:
359
+ raw_list.remove(key_val)
360
+ try:
361
+ for i in range(len(raw_list)):
362
+ if raw_list[i] == "name":
363
+ info["name"] = raw_list[i+1]
364
+ name_pos = i+1
365
+ elif raw_list[i] == "lastname":
366
+ info["lastname"] = raw_list[i+1]
367
+ lastname_pos = i+1
368
+ except:
369
+ pass
370
+
371
+ # กรณี หาอย่างใดอย่าหนึ่งเจอให้ลองข้ามไปดู 1 index name, "name_val", lastname , "lastname_val"
372
+ if (info["name"] != "None") and (info["lastname"] == "None"):
373
+ try:
374
+ info["lastname"] = raw_list[name_pos+2]
375
+ except:
376
+ pass
377
+ elif (info["lastname"] != "None") and (info["name"] == "None"):
378
+ try:
379
+ info["name"] = raw_list[lastname_pos-2]
380
+ except:
381
+ pass
382
+
383
+ # remove . on "mr." and "mrs."
384
+ info["name"] = info["name"].replace(".","")
385
+ info["lastname"] = info["lastname"].replace(".","")
386
+
387
+
388
+ return info
389
+
390
+ st.subheader("Process Completed!.....")
391
+ st.write(id_num)
392
+ st.write(name_sum(raw_data))
393
+
394
+
395
+
396
+
397
+ if choice =='About' :
398
+ st.header("About...")
399
+
400
+ st.subheader("AOC คืออะไร ?")
401
+ st.write("- เป็นระบบที่สามารถคัดกรองผลตรวจเชื้อของ COVID-19 ได้ผ่าน ที่ตรวจ ATK (Antigen Test Kit) ควบคู่กับบัตรประชาชน จากรูปภาพได้โดยอัตโนมัติ")
402
+
403
+ st.subheader("AOC ทำอะไรได้บ้าง ?")
404
+ st.write("- ตรวจจับผลตรวจ ATK (Obj detection)")
405
+ st.write("- ตรวจจับชื่อ-นามสกุล (OCR)")
406
+ st.write("- ตรวจจับเลขบัตรประชาชน (OCR)")
407
+
408
+ st.subheader("AOC ดีกว่ายังไง ?")
409
+ st.write("จากผลที่ได้จากการเปรียบเทียบกันระหว่าง model (AOC) กับ คน (Baseline) จำนวน 30 ภาพ / คน ได้ผลดังนี้")
410
+ st.image("./acc_table.png")
411
+ st.write("จากผลที่ได้สรุปได้ว่า ส่วนที่ผ่าน Baseline และมีประสิทธิภาพดีกว่าคัดกรองด้วยคนคือ ผลตรว�� ATK ได้ผลที่ 100 %, เลขบัตรประชน ได้ผลที่ 100 % และ ความเร็วในการคัดกรอง ได้ผลที่ 4.84 วินาที ซึ่งมีความเร็วมากกว่า 81% เมื่อเทียบกับคัดกรองด้วยคน ถือว่ามีประสิทธิภาพที่สูงมากในการคัดกรอง และ มีประสิทธิภาพมากกว่าการคัดแยกด้วยมนุษย์")
412
+ st.write("** ความเร็วที่โมเดลทำได้อาจไม่ตรงตามที่ deploy บนเว็บ เนื่องจากในเว็บ ไม่มี GPU ในการประมวลผลอาจทำให้โมเดลใช้เวลาในการประมวลที่นานกว่าตอนใช้ GPU")
413
+
414
+
415
+ st.subheader("คำแนะนำในการใช้งาน")
416
+ st.write("- ในการใช้งานให้ถ่ายรูปภาพบัตรประชาชนในแนวตั้งเท่านั้น เนื่องจากถ้าเป็นแนวอื่นอาจทำให้การตรวจจับคลาดเคลื่อนเอาได้")#3
417
+ st.write("- ภาพไม่ควรมีแสงที่สว่างมากเกืนไป และ มืดเกินไป มิฉะนั้นอาจทำให้การตรวจจับคลาดเคลื่อนเอาได้")#4
418
+ st.write("- ภาพไม่ควรที่จะอยู่ไกลเกินไป และ ควรมีความชัด มิฉะนั้นอาจทำให้การตรวจจับคลาดเคลื่อน หรือ ไม่สามารถตรวจจับได้")#5
419
+
420
+ st.subheader("รายละเอียดเพิ่มเติม")
421
+ st.write('[Medium blog](https://medium.com/@mjsalyjoh/atk-ocr-classification-aoc-%E0%B8%A3%E0%B8%B0%E0%B8%9A%E0%B8%9A%E0%B8%84%E0%B8%B1%E0%B8%94%E0%B8%81%E0%B8%A3%E0%B8%AD%E0%B8%87%E0%B8%9C%E0%B8%A5%E0%B8%95%E0%B8%A3%E0%B8%A7%E0%B8%88-atk-%E0%B9%81%E0%B8%A5%E0%B8%B0-%E0%B8%9A%E0%B8%B1%E0%B8%95%E0%B8%A3%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%8A%E0%B8%B2%E0%B8%8A%E0%B8%99-fa32a8d47599)')
422
+ st.write('[Github Link](https://github.com/Tanaanan/AOC_ATK_OCR_Classification)')
423
+
424
+
425
+
426
+
427
+ elif choice == "Detection":
428
+ st.header(" Antigen test kit + Identification card detector.")
429
+ pages_name = ['ATK + Idcard Detect', 'ATK Detect', 'Idcard Detect']
430
+ page = st.radio('Select option mode :', pages_name)
431
+
432
+ image = st.file_uploader(label = "upload ATK + Idcard img here.. OwO",type=['png','jpg','jpeg'])
433
+ if image is not None:
434
+ new_img = img_resize(image, 1280)
435
+ if page == "ATK + Idcard Detect":
436
+ st.image(get_img_detection(image))
437
+ with st.spinner("🤖 ATK + Idcard Working... "):
438
+
439
+ t1 = time.perf_counter()
440
+ Get_Idcard_detail(image)
441
+ get_detection(image)
442
+ t2 = time.perf_counter()
443
+ st.write('time taken to run: {:.2f} sec'.format(t2-t1))
444
+
445
+ elif page == "ATK Detect":
446
+ st.image(get_img_detection(image))
447
+ with st.spinner("🤖 ATK Working... "):
448
+ t1 = time.perf_counter()
449
+ st.subheader("Process Completed!.....")
450
+ get_detection(image)
451
+ t2 = time.perf_counter()
452
+ st.write('time taken to run: {:.2f} sec'.format(t2-t1))
453
+
454
+ elif page == "Idcard Detect":
455
+ st.image(new_img)
456
+ with st.spinner("🤖 Idcard Working... "):
457
+ t1 = time.perf_counter()
458
+ Get_Idcard_detail(image)
459
+ t2 = time.perf_counter()
460
+ st.write('time taken to run: {:.2f} sec'.format(t2-t1))
461
+
462
+
463
+
464
+
465
+
466
+ else:
467
+ st.write("## Waiting for image..")
468
+ st.image('atk_idcard.jpeg')
469
+
470
+ st.caption("Made by Tanaanan .M")
471
+
472
+
473
+ st.sidebar.subheader('More image for test..')
474
+ st.sidebar.write('[Github img test set.](https://github.com/Tanaanan/AOC_ATK_OCR_Classification/tree/main/test_set(img))')
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+ st.sidebar.markdown('---')
486
+ st.sidebar.subheader('Recomend / Issues report..')
487
+ st.sidebar.write('[Google form](https://forms.gle/zYpYFKcTpBoFGxN58)')
488
+
489
+
490
+ st.sidebar.markdown('---')
491
+ st.sidebar.subheader('Made by Tanaanan .M')
492
+ st.sidebar.write("Contact : mjsalyjoh@gmail.com")