Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
|
@@ -1,21 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
-
#pip install datasets transformers[sentencepiece]
|
| 3 |
-
#pip install accelerate
|
| 4 |
-
#apt install git-lfs
|
| 5 |
-
|
| 6 |
-
#sudo apt install tesseract-ocr
|
| 7 |
-
#pip install tesseract-ocr
|
| 8 |
-
#pip install pytesseract
|
| 9 |
-
#pip install keras-ocr
|
| 10 |
-
#pip install gradio
|
| 11 |
-
|
| 12 |
-
#importing required libraries
|
| 13 |
-
#import os
|
| 14 |
-
#os.system('apt-get install tesseract-ocr')
|
| 15 |
-
#os.system('pip install -q pytesseract')
|
| 16 |
-
#os.system('pip install pytesseract')
|
| 17 |
-
#sudo apt-get install tesseract-ocr
|
| 18 |
-
|
| 19 |
import pytesseract
|
| 20 |
from PIL import Image, ImageFont, ImageDraw
|
| 21 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
@@ -143,8 +126,8 @@ def translate_image(im, language):
|
|
| 143 |
|
| 144 |
#Enable writing on image
|
| 145 |
image_editable = ImageDraw.Draw(new_image)
|
| 146 |
-
image_editable.multiline_text((40,40), txt,spacing=2, font=title_font, fill= (0, 0, 0)) #(237, 230, 211))
|
| 147 |
-
return new_image
|
| 148 |
|
| 149 |
|
| 150 |
title = "Translate English Text to Your Regional Language In Your Forwarded Images"
|
|
@@ -154,10 +137,10 @@ pipeline = keras_ocr.pipeline.Pipeline()
|
|
| 154 |
gr.Interface(
|
| 155 |
translate_image,
|
| 156 |
[gr.inputs.Image(type="filepath", label="Input"), gr.inputs.Radio(choices=['hindi','spanish','french','turkish','german','irish', 'arabic'], type="value", default='hindi', label='Choose A Language')],
|
| 157 |
-
|
| 158 |
title=title,
|
| 159 |
description=description,
|
| 160 |
article=article,
|
| 161 |
-
|
| 162 |
enable_queue=True
|
| 163 |
).launch(debug=True)
|
|
|
|
| 1 |
+
#Import libraries
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import pytesseract
|
| 3 |
from PIL import Image, ImageFont, ImageDraw
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
| 126 |
|
| 127 |
#Enable writing on image
|
| 128 |
image_editable = ImageDraw.Draw(new_image)
|
| 129 |
+
image_editable.multiline_text((40,40), txt,spacing=2, font=title_font, fill= (0, 0, 0)) #(237, 230, 211)) Whites
|
| 130 |
+
return new_image
|
| 131 |
|
| 132 |
|
| 133 |
title = "Translate English Text to Your Regional Language In Your Forwarded Images"
|
|
|
|
| 137 |
gr.Interface(
|
| 138 |
translate_image,
|
| 139 |
[gr.inputs.Image(type="filepath", label="Input"), gr.inputs.Radio(choices=['hindi','spanish','french','turkish','german','irish', 'arabic'], type="value", default='hindi', label='Choose A Language')],
|
| 140 |
+
gr.outputs.Image(type="pil", label="Output"),
|
| 141 |
title=title,
|
| 142 |
description=description,
|
| 143 |
article=article,
|
| 144 |
+
examples=[['en2.jpg','hindi'],['gm1.jpg','hindi'],['quotes.jpg','spanish']],
|
| 145 |
enable_queue=True
|
| 146 |
).launch(debug=True)
|