ahmad4raza commited on
Commit
18a1106
·
1 Parent(s): a200808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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(url):
17
- model_1 = pipeline("image-to-text", model="microsoft/trocr-base-handwritten")
18
- output_1 = model_1(url)
19
- return output_1
 
 
 
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 = """