Spaces:
Sleeping
Sleeping
Update image_to_text.py
Browse files- image_to_text.py +6 -4
image_to_text.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
from PIL import Image
|
| 2 |
import pytesseract
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
-
def image_to_text(
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
| 1 |
from PIL import Image
|
| 2 |
import pytesseract
|
| 3 |
+
import io
|
| 4 |
|
| 5 |
|
| 6 |
+
def image_to_text(images):
|
| 7 |
+
img_bytes = io.BytesIO()
|
| 8 |
+
images.save(img_bytes, format='PNG')
|
| 9 |
+
text = pytesseract.image_to_string(Image.open(img_bytes))
|
| 10 |
+
return text
|