Omnibus commited on
Commit
2bf849d
·
1 Parent(s): 22d86e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +290 -27
app.py CHANGED
@@ -76,33 +76,20 @@ model7 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
76
  model8 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
77
  model9 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
78
  model10 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
79
- #model11 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
80
- #model12 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
81
- #model13 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
82
- #model14 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
83
- #model15 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
84
- #model16 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
85
- #model17 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
86
- #model18 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
87
- #model19 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
88
- #model20 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
89
  mylist = []
90
  myval = []
91
  for key in ocr_id.keys():
92
  mylist.append(key)
93
- #for value, key in ocr_id.items():
94
- # myval.append(value)
95
-
96
- #num1 =[]
97
- #num1.append(0)
98
-
99
-
100
- #targ=[]
101
- #targ.append(0)
102
-
103
- #targ_lang=[]
104
- #targ_lang.append(mylist[0])
105
- #print (targ_lang[0])
106
  ser_len=len(ocr_id)
107
 
108
 
@@ -120,6 +107,9 @@ def proc0(img):
120
  global targ_lang
121
  targ_lang=[]
122
  targ_lang.append(mylist[0])
 
 
 
123
 
124
  def proc1(img):
125
  new_num=len(num1)-1
@@ -141,13 +131,10 @@ def proc1(img):
141
 
142
  except Exception as e:
143
  out_a = f"Error:: {e} :: {num}"
144
-
145
  else:
146
  out_a = 'Done'
147
  pass
148
-
149
  out_p = f'{targ_lang[0]}: {targ[0]}'
150
-
151
  return (out_a, out_p)
152
 
153
  def proc2(img):
@@ -167,7 +154,6 @@ def proc2(img):
167
  else:
168
  pass
169
  out_a = f'{mylist[int(num)]}: {out}'
170
-
171
  except Exception as e:
172
  out_a = f"Error:: {e} :: {num}"
173
  else:
@@ -377,7 +363,261 @@ def proc10(img):
377
  pass
378
  out_p = f'{targ_lang[0]}: {targ[0]}'
379
  return (out_a, out_p)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
  with gr.Blocks() as app:
383
 
@@ -421,6 +661,18 @@ with gr.Blocks() as app:
421
  det_btn.click(proc9,[im],[out9,prob_lang], show_progress=False)
422
  det_btn.click(proc10,[im],[out10,prob_lang], show_progress=False)
423
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  out1.change(proc1,[im],[out1,prob_lang], show_progress=False)
425
  out2.change(proc2,[im],[out2,prob_lang], show_progress=False)
426
  out3.change(proc3,[im],[out3,prob_lang], show_progress=False)
@@ -431,6 +683,17 @@ with gr.Blocks() as app:
431
  out8.change(proc8,[im],[out8,prob_lang], show_progress=False)
432
  out9.change(proc9,[im],[out9,prob_lang], show_progress=False)
433
  out10.change(proc10,[im],[out10,prob_lang], show_progress=False)
 
 
 
 
 
 
 
 
 
 
 
434
 
435
  #det_btn.click(detect_lang,[im,ocr_sens,],det_out)
436
  app.queue(concurrency_count=100).launch()
 
76
  model8 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
77
  model9 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
78
  model10 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
79
+ model11 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
80
+ model12 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
81
+ model13 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
82
+ model14 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
83
+ model15 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
84
+ model16 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
85
+ model17 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
86
+ model18 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
87
+ model19 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
88
+ model20 = gr.Interface.load("spaces/Omnibus/detect-language-ocr")
89
  mylist = []
90
  myval = []
91
  for key in ocr_id.keys():
92
  mylist.append(key)
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ser_len=len(ocr_id)
94
 
95
 
 
107
  global targ_lang
108
  targ_lang=[]
109
  targ_lang.append(mylist[0])
110
+
111
+ #def main_proc()
112
+
113
 
114
  def proc1(img):
115
  new_num=len(num1)-1
 
131
 
132
  except Exception as e:
133
  out_a = f"Error:: {e} :: {num}"
 
134
  else:
135
  out_a = 'Done'
136
  pass
 
137
  out_p = f'{targ_lang[0]}: {targ[0]}'
 
138
  return (out_a, out_p)
139
 
140
  def proc2(img):
 
154
  else:
155
  pass
156
  out_a = f'{mylist[int(num)]}: {out}'
 
157
  except Exception as e:
158
  out_a = f"Error:: {e} :: {num}"
159
  else:
 
363
  pass
364
  out_p = f'{targ_lang[0]}: {targ[0]}'
365
  return (out_a, out_p)
366
+ ##################
367
+ def proc11(img):
368
+ new_num=len(num1)-1
369
+ num = new_num
370
+ print (f"new_num: {new_num}")
371
+ if int(num) <= (ser_len - 1):
372
+ num1.append(1)
373
+ lang = f"{ocr_id[mylist[int(num)]]}"
374
+ print(f"lang: {lang}")
375
+ out = model11(img,lang)
376
+ print (f'bounds: {out}')
377
+ try:
378
+ if float(out) > float(targ[0]):
379
+ targ[0]=out
380
+ targ_lang[0]=mylist[int(num)]
381
+ else:
382
+ pass
383
+ out_a = f'{mylist[int(num)]}: {out}'
384
+
385
+ except Exception as e:
386
+ out_a = f"Error:: {e} :: {num}"
387
+ else:
388
+ out_a = 'Done'
389
+ pass
390
+ out_p = f'{targ_lang[0]}: {targ[0]}'
391
+ return (out_a, out_p)
392
+
393
+ def proc12(img):
394
+ new_num=len(num1)-1
395
+ num = new_num
396
+ print (f"new_num: {new_num}")
397
+ if int(num) <= (ser_len - 1):
398
+ num1.append(1)
399
+ lang = f"{ocr_id[mylist[int(num)]]}"
400
+ print(f"lang: {lang}")
401
+ out = model12(img,lang)
402
+ print (f'bounds: {out}')
403
+ try:
404
+ if float(out) > float(targ[0]):
405
+ targ[0] = out
406
+ targ_lang[0]=mylist[int(num)]
407
+ else:
408
+ pass
409
+ out_a = f'{mylist[int(num)]}: {out}'
410
+ except Exception as e:
411
+ out_a = f"Error:: {e} :: {num}"
412
+ else:
413
+ out_a = 'Done'
414
+ pass
415
+ out_p = f'{targ_lang[0]}: {targ[0]}'
416
+ return (out_a, out_p)
417
+
418
+ def proc13(img):
419
+ new_num=len(num1)-1
420
+ num = new_num
421
+ print (f"new_num: {new_num}")
422
+ if int(num) <= (ser_len - 1):
423
+ num1.append(1)
424
+ lang = f"{ocr_id[mylist[int(num)]]}"
425
+ print(f"lang: {lang}")
426
+ out = model13(img,lang)
427
+ print (f'bounds: {out}')
428
+ try:
429
+ if float(out) > float(targ[0]):
430
+ targ[0] = out
431
+ targ_lang[0]=mylist[int(num)]
432
+ else:
433
+ pass
434
+ out_a = f'{mylist[int(num)]}: {out}'
435
+
436
+ except Exception as e:
437
+ out_a = f"Error:: {e} :: {num}"
438
+ else:
439
+ out_a = 'Done'
440
+ pass
441
+ out_p = f'{targ_lang[0]}: {targ[0]}'
442
+ return (out_a, out_p)
443
 
444
+ def proc14(img):
445
+ new_num=len(num1)-1
446
+ num = new_num
447
+ print (f"new_num: {new_num}")
448
+ if int(num) <= (ser_len - 1):
449
+ num1.append(1)
450
+ lang = f"{ocr_id[mylist[int(num)]]}"
451
+ print(f"lang: {lang}")
452
+ out = model14(img,lang)
453
+ print (f'bounds: {out}')
454
+ try:
455
+ if float(out) > float(targ[0]):
456
+ targ[0] = out
457
+ targ_lang[0]=mylist[int(num)]
458
+ else:
459
+ pass
460
+ out_a = f'{mylist[int(num)]}: {out}'
461
+
462
+ except Exception as e:
463
+ out_a = f"Error:: {e} :: {num}"
464
+ else:
465
+ out_a = 'Done'
466
+ pass
467
+ out_p = f'{targ_lang[0]}: {targ[0]}'
468
+ return (out_a, out_p)
469
+
470
+ def proc15(img):
471
+ new_num=len(num1)-1
472
+ num = new_num
473
+ print (f"new_num: {new_num}")
474
+ if int(num) <= (ser_len - 1):
475
+ num1.append(1)
476
+ lang = f"{ocr_id[mylist[int(num)]]}"
477
+ print(f"lang: {lang}")
478
+ out = model15(img,lang)
479
+ print (f'bounds: {out}')
480
+ try:
481
+ if float(out) > float(targ[0]):
482
+ targ[0] = out
483
+ targ_lang[0]=mylist[int(num)]
484
+ else:
485
+ pass
486
+ except Exception as e:
487
+ return f"Error:: {e}"
488
+ out_a = f'{mylist[int(num)]}: {out}'
489
+ else:
490
+ out_a = 'Done'
491
+ pass
492
+ out_p = f'{targ_lang[0]}: {targ[0]}'
493
+ return (out_a, out_p)
494
+
495
+ def proc16(img):
496
+ new_num=len(num1)-1
497
+ num = new_num
498
+ print (f"new_num: {new_num}")
499
+ if int(num) <= (ser_len - 1):
500
+ num1.append(1)
501
+ lang = f"{ocr_id[mylist[int(num)]]}"
502
+ print(f"lang: {lang}")
503
+ out = model16(img,lang)
504
+ print (f'bounds: {out}')
505
+ try:
506
+ if float(out) > float(targ[0]):
507
+ targ[0] = out
508
+ targ_lang[0]=mylist[int(num)]
509
+ else:
510
+ pass
511
+ except Exception as e:
512
+ return f"Error:: {e}"
513
+ out_a = f'{mylist[int(num)]}: {out}'
514
+ else:
515
+ out_a = 'Done'
516
+ pass
517
+ out_p = f'{targ_lang[0]}: {targ[0]}'
518
+ return (out_a, out_p)
519
+
520
+ def proc17(img):
521
+ new_num=len(num1)-1
522
+ num = new_num
523
+ print (f"new_num: {new_num}")
524
+ if int(num) <= (ser_len - 1):
525
+ num1.append(1)
526
+ lang = f"{ocr_id[mylist[int(num)]]}"
527
+ print(f"lang: {lang}")
528
+ out = model17(img,lang)
529
+ print (f'bounds: {out}')
530
+ try:
531
+ if float(out) > float(targ[0]):
532
+ targ[0] = out
533
+ targ_lang[0]=mylist[int(num)]
534
+ else:
535
+ pass
536
+ except Exception as e:
537
+ return f"Error:: {e}"
538
+ out_a = f'{mylist[int(num)]}: {out}'
539
+ else:
540
+ out_a = 'Done'
541
+ pass
542
+ out_p = f'{targ_lang[0]}: {targ[0]}'
543
+ return (out_a, out_p)
544
+
545
+ def proc18(img):
546
+ new_num=len(num1)-1
547
+ num = new_num
548
+ print (f"new_num: {new_num}")
549
+ if int(num) <= (ser_len - 1):
550
+ num1.append(1)
551
+ lang = f"{ocr_id[mylist[int(num)]]}"
552
+ print(f"lang: {lang}")
553
+ out = model18(img,lang)
554
+ print (f'bounds: {out}')
555
+ try:
556
+ if float(out) > float(targ[0]):
557
+ targ[0] = out
558
+ targ_lang[0]=mylist[int(num)]
559
+ else:
560
+ pass
561
+ except Exception as e:
562
+ return f"Error:: {e}"
563
+ out_a = f'{mylist[int(num)]}: {out}'
564
+ else:
565
+ out_a = 'Done'
566
+ pass
567
+ out_p = f'{targ_lang[0]}: {targ[0]}'
568
+ return (out_a, out_p)
569
+
570
+ def proc19(img):
571
+ new_num=len(num1)-1
572
+ num = new_num
573
+ print (f"new_num: {new_num}")
574
+ if int(num) <= (ser_len - 1):
575
+ num1.append(1)
576
+ lang = f"{ocr_id[mylist[int(num)]]}"
577
+ print(f"lang: {lang}")
578
+ out = model19(img,lang)
579
+ print (f'bounds: {out}')
580
+ try:
581
+ if float(out) > float(targ[0]):
582
+ targ[0] = out
583
+ targ_lang[0]=mylist[int(num)]
584
+ else:
585
+ pass
586
+ except Exception as e:
587
+ return f"Error:: {e}"
588
+ out_a = f'{mylist[int(num)]}: {out}'
589
+ else:
590
+ out_a = 'Done'
591
+ pass
592
+ out_p = f'{targ_lang[0]}: {targ[0]}'
593
+ return (out_a, out_p)
594
+
595
+ def proc20(img):
596
+ new_num=len(num1)-1
597
+ num = new_num
598
+ print (f"new_num: {new_num}")
599
+ if int(num) <= (ser_len - 1):
600
+ num1.append(1)
601
+ lang = f"{ocr_id[mylist[int(num)]]}"
602
+ print(f"lang: {lang}")
603
+ out = model20(img,lang)
604
+ print (f'bounds: {out}')
605
+ try:
606
+ if float(out) > float(targ[0]):
607
+ targ[0] = out
608
+ targ_lang[0]=mylist[int(num)]
609
+ else:
610
+ pass
611
+ except Exception as e:
612
+ return f"Error:: {e}"
613
+ out_a = f'{mylist[int(num)]}: {out}'
614
+ else:
615
+ out_a = 'Done'
616
+ pass
617
+ out_p = f'{targ_lang[0]}: {targ[0]}'
618
+ return (out_a, out_p)
619
+
620
+
621
 
622
  with gr.Blocks() as app:
623
 
 
661
  det_btn.click(proc9,[im],[out9,prob_lang], show_progress=False)
662
  det_btn.click(proc10,[im],[out10,prob_lang], show_progress=False)
663
 
664
+ det_btn.click(proc11,[im],[out11,prob_lang], show_progress=False)
665
+ det_btn.click(proc12,[im],[out12,prob_lang], show_progress=False)
666
+ det_btn.click(proc13,[im],[out13,prob_lang], show_progress=False)
667
+ det_btn.click(proc14,[im],[out14,prob_lang], show_progress=False)
668
+ det_btn.click(proc15,[im],[out15,prob_lang], show_progress=False)
669
+ det_btn.click(proc16,[im],[out16,prob_lang], show_progress=False)
670
+ det_btn.click(proc17,[im],[out17,prob_lang], show_progress=False)
671
+ det_btn.click(proc18,[im],[out18,prob_lang], show_progress=False)
672
+ det_btn.click(proc19,[im],[out19,prob_lang], show_progress=False)
673
+ det_btn.click(proc20,[im],[out20,prob_lang], show_progress=False)
674
+
675
+
676
  out1.change(proc1,[im],[out1,prob_lang], show_progress=False)
677
  out2.change(proc2,[im],[out2,prob_lang], show_progress=False)
678
  out3.change(proc3,[im],[out3,prob_lang], show_progress=False)
 
683
  out8.change(proc8,[im],[out8,prob_lang], show_progress=False)
684
  out9.change(proc9,[im],[out9,prob_lang], show_progress=False)
685
  out10.change(proc10,[im],[out10,prob_lang], show_progress=False)
686
+
687
+ out11.change(proc11,[im],[out1,prob_lang], show_progress=False)
688
+ out12.change(proc12,[im],[out2,prob_lang], show_progress=False)
689
+ out13.change(proc13,[im],[out3,prob_lang], show_progress=False)
690
+ out14.change(proc14,[im],[out4,prob_lang], show_progress=False)
691
+ out15.change(proc15,[im],[out5,prob_lang], show_progress=False)
692
+ out16.change(proc16,[im],[out6,prob_lang], show_progress=False)
693
+ out17.change(proc17,[im],[out7,prob_lang], show_progress=False)
694
+ out18.change(proc18,[im],[out8,prob_lang], show_progress=False)
695
+ out19.change(proc19,[im],[out9,prob_lang], show_progress=False)
696
+ out20.change(proc20,[im],[out10,prob_lang], show_progress=False)
697
 
698
  #det_btn.click(detect_lang,[im,ocr_sens,],det_out)
699
  app.queue(concurrency_count=100).launch()