Spaces:
Runtime error
Runtime error
import gradio as gr | |
import easyocr | |
import numpy as np | |
from PIL import Image | |
import uuid | |
import random | |
import time | |
uid=uuid.uuid4() | |
ocr_id = { | |
"Afrikaans": "af", | |
"Albanian": "sq", | |
"Arabic": "ar", | |
"Azerbaijani": "az", | |
"Belarusian": "be", | |
"Bulgarian": "bg", | |
"Bengali": "bn", | |
"Bosnian": "bs", | |
"Chinese (simplified)": "ch_sim", | |
"Chinese (traditional)": "ch_tra", | |
"Croatian": "hr", | |
"Czech": "cs", | |
"Danish": "da", | |
"Dutch": "nl", | |
"English": "en", | |
"Estonian": "et", | |
"French": "fr", | |
"German": "de", | |
"Irish": "ga", | |
"Hindi": "hi", | |
"Hungarian": "hu", | |
"Indonesian": "id", | |
"Icelandic": "is", | |
"Italian": "it", | |
"Japanese": "ja", | |
"Kannada": "kn", | |
"Korean": "ko", | |
"Lithuanian": "lt", | |
"Latvian": "lv", | |
"Mongolian": "mn", | |
"Marathi": "mr", | |
"Malay": "ms", | |
"Nepali": "ne", | |
"Norwegian": "no", | |
"Occitan": "oc", | |
"Polish": "pl", | |
"Portuguese": "pt", | |
"Romanian": "ro", | |
"Russian": "ru", | |
"Serbian (cyrillic)": "rs_cyrillic", | |
"Serbian (latin)": "rs_latin", | |
"Slovak": "sk", | |
"Slovenian": "sl", | |
"Spanish": "es", | |
"Swedish": "sv", | |
"Swahili": "sw", | |
"Tamil": "ta", | |
"Thai": "th", | |
"Tagalog": "tl", | |
"Turkish": "tr", | |
"Ukrainian": "uk", | |
"Urdu": "ur", | |
"Uzbek": "uz", | |
"Vietnamese": "vi", | |
"Welsh": "cy", | |
"Zulu": "zu", | |
} | |
model1 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model2 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model3 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model4 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model5 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model6 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model7 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model8 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model9 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model10 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model11 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model12 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model13 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model14 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model15 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model16 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model17 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model18 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model19 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model20 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model21 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model22 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model23 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model24 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model25 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model26 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model27 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model28 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model29 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model30 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model31 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model32 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model33 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model34 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model35 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model36 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model37 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model38 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model39 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model40 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model41 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model42 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model43 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model44 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model45 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model46 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model47 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model48 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model49 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model50 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model51 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model52 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model53 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model54 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model55 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model56 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model57 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model58 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model59 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
model60 = gr.Interface.load("spaces/Omnibus/detect-language-ocr") | |
mylist = [] | |
myval = [] | |
for key in ocr_id.keys(): | |
mylist.append(key) | |
ser_len=len(ocr_id) | |
def set_targ(): | |
targ = 0 | |
return targ | |
num1 = [] | |
targ = [] | |
targ_lang=[] | |
def proc0(img): | |
num1.clear() | |
num1.append(0) | |
targ.clear() | |
targ.append(0) | |
targ_lang.clear() | |
targ_lang.append(mylist[0]) | |
print ("LISTS CLEARED") | |
#def main_proc() | |
def proc1(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model1(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc2(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model2(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc3(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model3(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc4(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model4(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc5(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model5(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc6(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model6(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc7(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model7(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc8(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model8(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc9(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model9(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc10(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model10(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################## | |
def proc11(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model11(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc12(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model12(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc13(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model13(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc14(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model14(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc15(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model15(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc16(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model16(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc17(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model17(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc18(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model18(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc19(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model19(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc20(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model20(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################################### | |
def proc21(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model21(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc22(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model22(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc23(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model23(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc24(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model24(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc25(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model25(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc26(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model26(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc27(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model27(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc28(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model28(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc29(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model29(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc30(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model10(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################## | |
def proc31(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model31(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc32(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model32(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc33(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model33(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc34(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model34(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc35(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model35(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc36(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model36(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc37(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model37(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc38(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model38(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc39(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model39(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc40(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model40(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################## | |
def proc41(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model41(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc42(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model42(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc43(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model43(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc44(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model44(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc45(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model45(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc46(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model46(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc47(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model47(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc48(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model48(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc49(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model9(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc50(img): | |
rand = random.randint(100,5000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model10(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################## | |
def proc51(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model51(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0]=out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc52(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model52(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc53(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model53(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc54(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model54(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
out_a = f'{mylist[int(num)]}: {out}' | |
except Exception as e: | |
out_a = f"Error:: {e} :: {num}" | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc55(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model55(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc56(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model56(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc57(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model57(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc58(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model58(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc59(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model59(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
def proc60(img): | |
rand = random.randint(1,3000) | |
time.sleep(rand/1000) | |
new_num=len(num1)-1 | |
num = new_num | |
print (f"new_num: {new_num}") | |
if int(num) <= (ser_len - 1): | |
num1.append(1) | |
lang = f"{ocr_id[mylist[int(num)]]}" | |
print(f"lang: {lang}") | |
out = model60(img,lang) | |
print (f'bounds: {out}') | |
try: | |
if float(out) > float(targ[0]): | |
targ[0] = out | |
targ_lang[0]=mylist[int(num)] | |
else: | |
pass | |
except Exception as e: | |
return f"Error:: {e}" | |
out_a = f'{mylist[int(num)]}: {out}' | |
else: | |
out_a = 'Done' | |
pass | |
out_p = f'{targ_lang[0]}: {targ[0]}' | |
return (out_a, out_p) | |
################## | |
################## | |
with gr.Blocks() as app: | |
im = gr.Image(type = "filepath") | |
ocr_sens=gr.Slider(0.1, 1, step=0.05,value=0.25,label="Detect Min Confidence") | |
max_tok=gr.Number(label="Max Tokens",step=1, value=200) | |
prob_lang = gr.Textbox(label="Probable Language:") | |
det_btn = gr.Button() | |
with gr.Accordion("process", open = False): | |
out1=gr.Textbox() | |
out2=gr.Textbox() | |
out3=gr.Textbox() | |
out4=gr.Textbox() | |
out5=gr.Textbox() | |
out6=gr.Textbox() | |
out7=gr.Textbox() | |
out8=gr.Textbox() | |
out9=gr.Textbox() | |
out10=gr.Textbox() | |
out11=gr.Textbox() | |
out12=gr.Textbox() | |
out13=gr.Textbox() | |
out14=gr.Textbox() | |
out15=gr.Textbox() | |
out16=gr.Textbox() | |
out17=gr.Textbox() | |
out18=gr.Textbox() | |
out19=gr.Textbox() | |
out20=gr.Textbox() | |
out21=gr.Textbox() | |
out22=gr.Textbox() | |
out23=gr.Textbox() | |
out24=gr.Textbox() | |
out25=gr.Textbox() | |
out26=gr.Textbox() | |
out27=gr.Textbox() | |
out28=gr.Textbox() | |
out29=gr.Textbox() | |
out30=gr.Textbox() | |
out31=gr.Textbox() | |
out32=gr.Textbox() | |
out33=gr.Textbox() | |
out34=gr.Textbox() | |
out35=gr.Textbox() | |
out36=gr.Textbox() | |
out37=gr.Textbox() | |
out38=gr.Textbox() | |
out39=gr.Textbox() | |
out40=gr.Textbox() | |
out41=gr.Textbox() | |
out42=gr.Textbox() | |
out43=gr.Textbox() | |
out44=gr.Textbox() | |
out45=gr.Textbox() | |
out46=gr.Textbox() | |
out47=gr.Textbox() | |
out48=gr.Textbox() | |
out49=gr.Textbox() | |
out50=gr.Textbox() | |
out51=gr.Textbox() | |
out52=gr.Textbox() | |
out53=gr.Textbox() | |
out54=gr.Textbox() | |
out55=gr.Textbox() | |
out56=gr.Textbox() | |
out57=gr.Textbox() | |
out58=gr.Textbox() | |
out59=gr.Textbox() | |
out60=gr.Textbox() | |
det_btn.click(proc0,None,None, show_progress=False) | |
det_btn.click(proc1,[im],[out1,prob_lang], show_progress=True) | |
det_btn.click(proc2,[im],[out2,prob_lang], show_progress=True) | |
det_btn.click(proc3,[im],[out3,prob_lang], show_progress=True) | |
det_btn.click(proc4,[im],[out4,prob_lang], show_progress=True) | |
det_btn.click(proc5,[im],[out5,prob_lang], show_progress=True) | |
det_btn.click(proc6,[im],[out6,prob_lang], show_progress=True) | |
det_btn.click(proc7,[im],[out7,prob_lang], show_progress=True) | |
det_btn.click(proc8,[im],[out8,prob_lang], show_progress=True) | |
det_btn.click(proc9,[im],[out9,prob_lang], show_progress=True) | |
det_btn.click(proc10,[im],[out10,prob_lang], show_progress=True) | |
det_btn.click(proc11,[im],[out11,prob_lang], show_progress=True) | |
det_btn.click(proc12,[im],[out12,prob_lang], show_progress=True) | |
det_btn.click(proc13,[im],[out13,prob_lang], show_progress=True) | |
det_btn.click(proc14,[im],[out14,prob_lang], show_progress=True) | |
det_btn.click(proc15,[im],[out15,prob_lang], show_progress=True) | |
det_btn.click(proc16,[im],[out16,prob_lang], show_progress=True) | |
det_btn.click(proc17,[im],[out17,prob_lang], show_progress=True) | |
det_btn.click(proc18,[im],[out18,prob_lang], show_progress=True) | |
det_btn.click(proc19,[im],[out19,prob_lang], show_progress=True) | |
det_btn.click(proc20,[im],[out20,prob_lang], show_progress=True) | |
det_btn.click(proc21,[im],[out21,prob_lang], show_progress=True) | |
det_btn.click(proc22,[im],[out22,prob_lang], show_progress=True) | |
det_btn.click(proc23,[im],[out23,prob_lang], show_progress=True) | |
det_btn.click(proc24,[im],[out24,prob_lang], show_progress=True) | |
det_btn.click(proc25,[im],[out25,prob_lang], show_progress=True) | |
det_btn.click(proc26,[im],[out26,prob_lang], show_progress=True) | |
det_btn.click(proc27,[im],[out27,prob_lang], show_progress=True) | |
det_btn.click(proc28,[im],[out28,prob_lang], show_progress=True) | |
det_btn.click(proc29,[im],[out29,prob_lang], show_progress=True) | |
det_btn.click(proc30,[im],[out30,prob_lang], show_progress=True) | |
det_btn.click(proc31,[im],[out31,prob_lang], show_progress=True) | |
det_btn.click(proc32,[im],[out32,prob_lang], show_progress=True) | |
det_btn.click(proc33,[im],[out33,prob_lang], show_progress=True) | |
det_btn.click(proc34,[im],[out34,prob_lang], show_progress=True) | |
det_btn.click(proc35,[im],[out35,prob_lang], show_progress=True) | |
det_btn.click(proc36,[im],[out36,prob_lang], show_progress=True) | |
det_btn.click(proc37,[im],[out37,prob_lang], show_progress=True) | |
det_btn.click(proc38,[im],[out38,prob_lang], show_progress=True) | |
det_btn.click(proc39,[im],[out39,prob_lang], show_progress=True) | |
det_btn.click(proc40,[im],[out40,prob_lang], show_progress=True) | |
det_btn.click(proc41,[im],[out41,prob_lang], show_progress=True) | |
det_btn.click(proc42,[im],[out42,prob_lang], show_progress=True) | |
det_btn.click(proc43,[im],[out43,prob_lang], show_progress=True) | |
det_btn.click(proc44,[im],[out44,prob_lang], show_progress=True) | |
det_btn.click(proc45,[im],[out45,prob_lang], show_progress=True) | |
det_btn.click(proc46,[im],[out46,prob_lang], show_progress=True) | |
det_btn.click(proc47,[im],[out47,prob_lang], show_progress=True) | |
det_btn.click(proc48,[im],[out48,prob_lang], show_progress=True) | |
det_btn.click(proc49,[im],[out49,prob_lang], show_progress=True) | |
det_btn.click(proc50,[im],[out50,prob_lang], show_progress=True) | |
det_btn.click(proc51,[im],[out51,prob_lang], show_progress=True) | |
det_btn.click(proc52,[im],[out52,prob_lang], show_progress=True) | |
det_btn.click(proc53,[im],[out53,prob_lang], show_progress=True) | |
det_btn.click(proc54,[im],[out54,prob_lang], show_progress=True) | |
det_btn.click(proc55,[im],[out55,prob_lang], show_progress=True) | |
det_btn.click(proc56,[im],[out56,prob_lang], show_progress=True) | |
det_btn.click(proc57,[im],[out57,prob_lang], show_progress=True) | |
det_btn.click(proc58,[im],[out58,prob_lang], show_progress=True) | |
det_btn.click(proc59,[im],[out59,prob_lang], show_progress=True) | |
det_btn.click(proc60,[im],[out60,prob_lang], show_progress=True) | |
#det_btn.click(detect_lang,[im,ocr_sens,],det_out) | |
app.queue(concurrency_count=500).launch(max_threads=500) |