Soumen commited on
Commit
b446f5c
1 Parent(s): a07988a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -54,8 +54,16 @@ import altair as alt
54
  from PIL import Image
55
  API_URL = "https://api-inference.huggingface.co/models/gpt2-large"
56
  headers = {"Authorization": "Bearer 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"}
57
- API_URL0 = "https://api-inference.huggingface.co/models/t5-base"
58
  headers0 = {"Authorization": "Bearer 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"}
 
 
 
 
 
 
 
 
59
  def read_pdf(file):
60
  # images=pdf2image.convert_from_path(file)
61
  # # print(type(images))
@@ -160,13 +168,13 @@ def main():
160
  #ret,thresh1 = cv2.threshold(imge,120,255,cv2.THRESH_BINARY)
161
  # pytesseract image to string to get results
162
  #text = str(pytesseract.image_to_string(img, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
163
- text = pytesseract.image_to_string(img) #pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else
164
  st.success(text)
165
  elif camera_photo:
166
  img = Image.open(camera_photo)
167
  img = img.save("img.png")
168
  img = cv2.imread("img.png")
169
- text = pytesseract.image_to_string(img) #pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
170
  st.success(text)
171
  elif uploaded_photo==None and camera_photo==None:
172
  #our_image=load_image("image.jpg")
@@ -191,7 +199,7 @@ def main():
191
  "inputs": text,
192
  })
193
  st.success(output)
194
- if st.checkbox("Mark to English Text Summarization!"):
195
  def query(payload):
196
  response = requests.post(API_URL0, headers=headers0, json=payload)
197
  return response.json()
 
54
  from PIL import Image
55
  API_URL = "https://api-inference.huggingface.co/models/gpt2-large"
56
  headers = {"Authorization": "Bearer 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"}
57
+ API_URL0 = "https://api-inference.huggingface.co/models/csebuetnlp/mT5_multilingual_XLSum"
58
  headers0 = {"Authorization": "Bearer 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"}
59
+
60
+ def query(payload):
61
+ response = requests.post(API_URL, headers=headers, json=payload)
62
+ return response.json()
63
+
64
+ output = query({
65
+ "inputs": "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.",
66
+ })
67
  def read_pdf(file):
68
  # images=pdf2image.convert_from_path(file)
69
  # # print(type(images))
 
168
  #ret,thresh1 = cv2.threshold(imge,120,255,cv2.THRESH_BINARY)
169
  # pytesseract image to string to get results
170
  #text = str(pytesseract.image_to_string(img, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
171
+ text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
172
  st.success(text)
173
  elif camera_photo:
174
  img = Image.open(camera_photo)
175
  img = img.save("img.png")
176
  img = cv2.imread("img.png")
177
+ text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
178
  st.success(text)
179
  elif uploaded_photo==None and camera_photo==None:
180
  #our_image=load_image("image.jpg")
 
199
  "inputs": text,
200
  })
201
  st.success(output)
202
+ if st.checkbox("Mark to Bangla Text Summarization!"):
203
  def query(payload):
204
  response = requests.post(API_URL0, headers=headers0, json=payload)
205
  return response.json()