Spaces:
Runtime error
Runtime error
tired as f to fix it
Browse files
routes/aminoOSRapi/main.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
import pytesseract
|
| 3 |
-
from io import BytesIO
|
| 4 |
from PIL import Image, ImageEnhance
|
| 5 |
|
| 6 |
def apipredict(request):
|
|
@@ -21,8 +22,13 @@ def apipredict(request):
|
|
| 21 |
if pix[x, y] == forReplace:
|
| 22 |
image.putpixel((x, y), newColor)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
pix = image.load()
|
| 28 |
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import string
|
| 3 |
import requests
|
| 4 |
import pytesseract
|
|
|
|
| 5 |
from PIL import Image, ImageEnhance
|
| 6 |
|
| 7 |
def apipredict(request):
|
|
|
|
| 22 |
if pix[x, y] == forReplace:
|
| 23 |
image.putpixel((x, y), newColor)
|
| 24 |
|
| 25 |
+
name = ''.join([random.choice(string.ascii_lowercase) for _ in range(random.randint(6,12)])
|
| 26 |
+
response = requests.get(url)
|
| 27 |
+
with open(f'{name}.png', 'wb') as fp:
|
| 28 |
+
fp.write(response.content)
|
| 29 |
+
|
| 30 |
+
with open(f'{name}.png', 'rb') as fp:
|
| 31 |
+
image = Image.open(fp)
|
| 32 |
|
| 33 |
pix = image.load()
|
| 34 |
|