Spaces:
Sleeping
Sleeping
Commit
·
18a1106
1
Parent(s):
a200808
Update app.py
Browse files
app.py
CHANGED
@@ -13,10 +13,13 @@ import numpy as np
|
|
13 |
from dotenv import load_dotenv, find_dotenv
|
14 |
load_dotenv(find_dotenv())
|
15 |
|
16 |
-
def handwriting_to_text(
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
|
21 |
def generate_story(scenario):
|
22 |
template = """
|
|
|
13 |
from dotenv import load_dotenv, find_dotenv
|
14 |
load_dotenv(find_dotenv())
|
15 |
|
16 |
+
def handwriting_to_text(image):
|
17 |
+
API_URL = "https://api-inference.huggingface.co/models/microsoft/trocr-base-handwritten"
|
18 |
+
headers = {"Authorization": "Bearer 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"}
|
19 |
+
with open(image, "rb") as f:
|
20 |
+
data = f.read()
|
21 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
22 |
+
return response.json()
|
23 |
|
24 |
def generate_story(scenario):
|
25 |
template = """
|