Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,14 +66,14 @@ ocr_id = {
|
|
| 66 |
|
| 67 |
model1 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 68 |
model2 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
#model11 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 78 |
#model12 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 79 |
#model13 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
|
@@ -150,7 +150,6 @@ def proc2(img):
|
|
| 150 |
if float(out) > float(targ[0]):
|
| 151 |
targ[0] = out
|
| 152 |
targ_lang[0]=mylist[int(num)]
|
| 153 |
-
|
| 154 |
else:
|
| 155 |
pass
|
| 156 |
except Exception as e:
|
|
@@ -160,6 +159,193 @@ def proc2(img):
|
|
| 160 |
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 161 |
return (targ[0], out_p)
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
with gr.Blocks() as app:
|
|
@@ -197,9 +383,25 @@ with gr.Blocks() as app:
|
|
| 197 |
|
| 198 |
det_btn.click(proc1,[im],[out1,prob_lang], show_progress=False)
|
| 199 |
det_btn.click(proc2,[im],[out2,prob_lang], show_progress=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
out1.change(proc1,[im],[out1,prob_lang], show_progress=False)
|
| 202 |
out2.change(proc2,[im],[out2,prob_lang], show_progress=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
#det_btn.click(detect_lang,[im,ocr_sens,],det_out)
|
| 205 |
app.launch()
|
|
|
|
| 66 |
|
| 67 |
model1 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 68 |
model2 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 69 |
+
model3 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 70 |
+
model4 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 71 |
+
model5 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 72 |
+
model6 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 73 |
+
model7 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 74 |
+
model8 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 75 |
+
model9 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 76 |
+
model10 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 77 |
#model11 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 78 |
#model12 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
| 79 |
#model13 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
|
|
|
|
| 150 |
if float(out) > float(targ[0]):
|
| 151 |
targ[0] = out
|
| 152 |
targ_lang[0]=mylist[int(num)]
|
|
|
|
| 153 |
else:
|
| 154 |
pass
|
| 155 |
except Exception as e:
|
|
|
|
| 159 |
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 160 |
return (targ[0], out_p)
|
| 161 |
|
| 162 |
+
def proc3(img):
|
| 163 |
+
new_num=len(num1)-1
|
| 164 |
+
num = new_num
|
| 165 |
+
print (f"new_num: {new_num}")
|
| 166 |
+
if int(num) <= (ser_len - 1):
|
| 167 |
+
num1.append(1)
|
| 168 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 169 |
+
print(f"lang: {lang}")
|
| 170 |
+
out = model3(img,lang)
|
| 171 |
+
print (f'bounds: {out}')
|
| 172 |
+
try:
|
| 173 |
+
if float(out) > float(targ[0]):
|
| 174 |
+
targ[0] = out
|
| 175 |
+
targ_lang[0]=mylist[int(num)]
|
| 176 |
+
else:
|
| 177 |
+
pass
|
| 178 |
+
except Exception as e:
|
| 179 |
+
return f"Error:: {e}"
|
| 180 |
+
else:
|
| 181 |
+
pass
|
| 182 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 183 |
+
return (targ[0], out_p)
|
| 184 |
+
|
| 185 |
+
def proc4(img):
|
| 186 |
+
new_num=len(num1)-1
|
| 187 |
+
num = new_num
|
| 188 |
+
print (f"new_num: {new_num}")
|
| 189 |
+
if int(num) <= (ser_len - 1):
|
| 190 |
+
num1.append(1)
|
| 191 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 192 |
+
print(f"lang: {lang}")
|
| 193 |
+
out = model4(img,lang)
|
| 194 |
+
print (f'bounds: {out}')
|
| 195 |
+
try:
|
| 196 |
+
if float(out) > float(targ[0]):
|
| 197 |
+
targ[0] = out
|
| 198 |
+
targ_lang[0]=mylist[int(num)]
|
| 199 |
+
else:
|
| 200 |
+
pass
|
| 201 |
+
except Exception as e:
|
| 202 |
+
return f"Error:: {e}"
|
| 203 |
+
else:
|
| 204 |
+
pass
|
| 205 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 206 |
+
return (targ[0], out_p)
|
| 207 |
+
|
| 208 |
+
def proc5(img):
|
| 209 |
+
new_num=len(num1)-1
|
| 210 |
+
num = new_num
|
| 211 |
+
print (f"new_num: {new_num}")
|
| 212 |
+
if int(num) <= (ser_len - 1):
|
| 213 |
+
num1.append(1)
|
| 214 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 215 |
+
print(f"lang: {lang}")
|
| 216 |
+
out = model5(img,lang)
|
| 217 |
+
print (f'bounds: {out}')
|
| 218 |
+
try:
|
| 219 |
+
if float(out) > float(targ[0]):
|
| 220 |
+
targ[0] = out
|
| 221 |
+
targ_lang[0]=mylist[int(num)]
|
| 222 |
+
else:
|
| 223 |
+
pass
|
| 224 |
+
except Exception as e:
|
| 225 |
+
return f"Error:: {e}"
|
| 226 |
+
else:
|
| 227 |
+
pass
|
| 228 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 229 |
+
return (targ[0], out_p)
|
| 230 |
+
|
| 231 |
+
def proc6(img):
|
| 232 |
+
new_num=len(num1)-1
|
| 233 |
+
num = new_num
|
| 234 |
+
print (f"new_num: {new_num}")
|
| 235 |
+
if int(num) <= (ser_len - 1):
|
| 236 |
+
num1.append(1)
|
| 237 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 238 |
+
print(f"lang: {lang}")
|
| 239 |
+
out = model6(img,lang)
|
| 240 |
+
print (f'bounds: {out}')
|
| 241 |
+
try:
|
| 242 |
+
if float(out) > float(targ[0]):
|
| 243 |
+
targ[0] = out
|
| 244 |
+
targ_lang[0]=mylist[int(num)]
|
| 245 |
+
else:
|
| 246 |
+
pass
|
| 247 |
+
except Exception as e:
|
| 248 |
+
return f"Error:: {e}"
|
| 249 |
+
else:
|
| 250 |
+
pass
|
| 251 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 252 |
+
return (targ[0], out_p)
|
| 253 |
+
|
| 254 |
+
def proc7(img):
|
| 255 |
+
new_num=len(num1)-1
|
| 256 |
+
num = new_num
|
| 257 |
+
print (f"new_num: {new_num}")
|
| 258 |
+
if int(num) <= (ser_len - 1):
|
| 259 |
+
num1.append(1)
|
| 260 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 261 |
+
print(f"lang: {lang}")
|
| 262 |
+
out = model7(img,lang)
|
| 263 |
+
print (f'bounds: {out}')
|
| 264 |
+
try:
|
| 265 |
+
if float(out) > float(targ[0]):
|
| 266 |
+
targ[0] = out
|
| 267 |
+
targ_lang[0]=mylist[int(num)]
|
| 268 |
+
else:
|
| 269 |
+
pass
|
| 270 |
+
except Exception as e:
|
| 271 |
+
return f"Error:: {e}"
|
| 272 |
+
else:
|
| 273 |
+
pass
|
| 274 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 275 |
+
return (targ[0], out_p)
|
| 276 |
+
|
| 277 |
+
def proc8(img):
|
| 278 |
+
new_num=len(num1)-1
|
| 279 |
+
num = new_num
|
| 280 |
+
print (f"new_num: {new_num}")
|
| 281 |
+
if int(num) <= (ser_len - 1):
|
| 282 |
+
num1.append(1)
|
| 283 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 284 |
+
print(f"lang: {lang}")
|
| 285 |
+
out = model8(img,lang)
|
| 286 |
+
print (f'bounds: {out}')
|
| 287 |
+
try:
|
| 288 |
+
if float(out) > float(targ[0]):
|
| 289 |
+
targ[0] = out
|
| 290 |
+
targ_lang[0]=mylist[int(num)]
|
| 291 |
+
else:
|
| 292 |
+
pass
|
| 293 |
+
except Exception as e:
|
| 294 |
+
return f"Error:: {e}"
|
| 295 |
+
else:
|
| 296 |
+
pass
|
| 297 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 298 |
+
return (targ[0], out_p)
|
| 299 |
+
|
| 300 |
+
def proc9(img):
|
| 301 |
+
new_num=len(num1)-1
|
| 302 |
+
num = new_num
|
| 303 |
+
print (f"new_num: {new_num}")
|
| 304 |
+
if int(num) <= (ser_len - 1):
|
| 305 |
+
num1.append(1)
|
| 306 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 307 |
+
print(f"lang: {lang}")
|
| 308 |
+
out = model9(img,lang)
|
| 309 |
+
print (f'bounds: {out}')
|
| 310 |
+
try:
|
| 311 |
+
if float(out) > float(targ[0]):
|
| 312 |
+
targ[0] = out
|
| 313 |
+
targ_lang[0]=mylist[int(num)]
|
| 314 |
+
else:
|
| 315 |
+
pass
|
| 316 |
+
except Exception as e:
|
| 317 |
+
return f"Error:: {e}"
|
| 318 |
+
else:
|
| 319 |
+
pass
|
| 320 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 321 |
+
return (targ[0], out_p)
|
| 322 |
+
|
| 323 |
+
def proc10(img):
|
| 324 |
+
new_num=len(num1)-1
|
| 325 |
+
num = new_num
|
| 326 |
+
print (f"new_num: {new_num}")
|
| 327 |
+
if int(num) <= (ser_len - 1):
|
| 328 |
+
num1.append(1)
|
| 329 |
+
lang = f"{ocr_id[mylist[int(num)]]}"
|
| 330 |
+
print(f"lang: {lang}")
|
| 331 |
+
out = model10(img,lang)
|
| 332 |
+
print (f'bounds: {out}')
|
| 333 |
+
try:
|
| 334 |
+
if float(out) > float(targ[0]):
|
| 335 |
+
targ[0] = out
|
| 336 |
+
targ_lang[0]=mylist[int(num)]
|
| 337 |
+
else:
|
| 338 |
+
pass
|
| 339 |
+
except Exception as e:
|
| 340 |
+
return f"Error:: {e}"
|
| 341 |
+
else:
|
| 342 |
+
pass
|
| 343 |
+
out_p = f'{targ_lang[0]}: {targ[0]}'
|
| 344 |
+
return (targ[0], out_p)
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
|
| 349 |
|
| 350 |
|
| 351 |
with gr.Blocks() as app:
|
|
|
|
| 383 |
|
| 384 |
det_btn.click(proc1,[im],[out1,prob_lang], show_progress=False)
|
| 385 |
det_btn.click(proc2,[im],[out2,prob_lang], show_progress=False)
|
| 386 |
+
det_btn.click(proc3,[im],[out3,prob_lang], show_progress=False)
|
| 387 |
+
det_btn.click(proc4,[im],[out4,prob_lang], show_progress=False)
|
| 388 |
+
det_btn.click(proc5,[im],[out5,prob_lang], show_progress=False)
|
| 389 |
+
det_btn.click(proc6,[im],[out6,prob_lang], show_progress=False)
|
| 390 |
+
det_btn.click(proc7,[im],[out7,prob_lang], show_progress=False)
|
| 391 |
+
det_btn.click(proc8,[im],[out8,prob_lang], show_progress=False)
|
| 392 |
+
det_btn.click(proc9,[im],[out9,prob_lang], show_progress=False)
|
| 393 |
+
det_btn.click(proc10,[im],[out10,prob_lang], show_progress=False)
|
| 394 |
|
| 395 |
out1.change(proc1,[im],[out1,prob_lang], show_progress=False)
|
| 396 |
out2.change(proc2,[im],[out2,prob_lang], show_progress=False)
|
| 397 |
+
out3.change(proc2,[im],[out3,prob_lang], show_progress=False)
|
| 398 |
+
out4.change(proc2,[im],[out4,prob_lang], show_progress=False)
|
| 399 |
+
out5.change(proc2,[im],[out5,prob_lang], show_progress=False)
|
| 400 |
+
out6.change(proc2,[im],[out6,prob_lang], show_progress=False)
|
| 401 |
+
out7.change(proc2,[im],[out7,prob_lang], show_progress=False)
|
| 402 |
+
out8.change(proc2,[im],[out8,prob_lang], show_progress=False)
|
| 403 |
+
out9.change(proc2,[im],[out9,prob_lang], show_progress=False)
|
| 404 |
+
out10.change(proc2,[im],[out10,prob_lang], show_progress=False)
|
| 405 |
|
| 406 |
#det_btn.click(detect_lang,[im,ocr_sens,],det_out)
|
| 407 |
app.launch()
|