Spaces:
Sleeping
Sleeping
Update button_click_alt.py
Browse files- button_click_alt.py +1 -7
button_click_alt.py
CHANGED
|
@@ -17,18 +17,13 @@ def infer_text(im):
|
|
| 17 |
"media_type": (None, "photo"),
|
| 18 |
}
|
| 19 |
headers = {"referer": "https://thehive.ai/"}
|
| 20 |
-
|
| 21 |
res = requests.post(url, headers=headers, files=files)
|
| 22 |
-
|
| 23 |
text = ""
|
| 24 |
for output in res.json()["response"]["output"]:
|
| 25 |
text += output["block_text"]
|
| 26 |
-
|
| 27 |
text = decode(encode(text, "latin-1", "backslashreplace"), "unicode-escape")
|
| 28 |
-
|
| 29 |
return text
|
| 30 |
|
| 31 |
-
|
| 32 |
def find_order_id(uploaded_file, input_file, model, ocre):
|
| 33 |
if ocre == 'Hive':
|
| 34 |
uploaded_image = Image.open(uploaded_file)
|
|
@@ -36,8 +31,7 @@ def find_order_id(uploaded_file, input_file, model, ocre):
|
|
| 36 |
else:
|
| 37 |
rotated = preprocess_image(uploaded_file)
|
| 38 |
text = pytesseract.image_to_string(rotated)
|
| 39 |
-
|
| 40 |
-
|
| 41 |
with input_file as file:
|
| 42 |
file_contents = file.read().decode()
|
| 43 |
lines = file_contents.split('\n')
|
|
|
|
| 17 |
"media_type": (None, "photo"),
|
| 18 |
}
|
| 19 |
headers = {"referer": "https://thehive.ai/"}
|
|
|
|
| 20 |
res = requests.post(url, headers=headers, files=files)
|
|
|
|
| 21 |
text = ""
|
| 22 |
for output in res.json()["response"]["output"]:
|
| 23 |
text += output["block_text"]
|
|
|
|
| 24 |
text = decode(encode(text, "latin-1", "backslashreplace"), "unicode-escape")
|
|
|
|
| 25 |
return text
|
| 26 |
|
|
|
|
| 27 |
def find_order_id(uploaded_file, input_file, model, ocre):
|
| 28 |
if ocre == 'Hive':
|
| 29 |
uploaded_image = Image.open(uploaded_file)
|
|
|
|
| 31 |
else:
|
| 32 |
rotated = preprocess_image(uploaded_file)
|
| 33 |
text = pytesseract.image_to_string(rotated)
|
| 34 |
+
|
|
|
|
| 35 |
with input_file as file:
|
| 36 |
file_contents = file.read().decode()
|
| 37 |
lines = file_contents.split('\n')
|