Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +29 -0
- requirements.txt +45 -0
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import pytesseract
|
| 4 |
+
|
| 5 |
+
pytesseract.pytesseract.tesseract_cmd = "/opt/homebrew/bin/tesseract"
|
| 6 |
+
|
| 7 |
+
def extract_text(image):
|
| 8 |
+
try:
|
| 9 |
+
text = pytesseract.image_to_string(image, lang='eng',config='--psm 1')
|
| 10 |
+
return text
|
| 11 |
+
except Exception as e:
|
| 12 |
+
return str(e)
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
st.title("Text Extraction from Image in English and Tamil")
|
| 16 |
+
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 17 |
+
|
| 18 |
+
if uploaded_file is not None:
|
| 19 |
+
image = Image.open(uploaded_file)
|
| 20 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 21 |
+
|
| 22 |
+
text = extract_text(image)
|
| 23 |
+
|
| 24 |
+
st.success("Text extracted successfully!")
|
| 25 |
+
st.header("Extracted Text:")
|
| 26 |
+
st.write(text)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
altair==5.2.0
|
| 2 |
+
attrs==23.2.0
|
| 3 |
+
blinker==1.7.0
|
| 4 |
+
cachetools==5.3.2
|
| 5 |
+
certifi==2024.2.2
|
| 6 |
+
charset-normalizer==3.3.2
|
| 7 |
+
click==8.1.7
|
| 8 |
+
gitdb==4.0.11
|
| 9 |
+
GitPython==3.1.42
|
| 10 |
+
idna==3.6
|
| 11 |
+
importlib-metadata==7.0.1
|
| 12 |
+
Jinja2==3.1.3
|
| 13 |
+
jsonschema==4.21.1
|
| 14 |
+
jsonschema-specifications==2023.12.1
|
| 15 |
+
markdown-it-py==3.0.0
|
| 16 |
+
MarkupSafe==2.1.5
|
| 17 |
+
mdurl==0.1.2
|
| 18 |
+
numpy==1.26.4
|
| 19 |
+
packaging==23.2
|
| 20 |
+
pandas==2.2.0
|
| 21 |
+
pillow==10.2.0
|
| 22 |
+
protobuf==4.25.3
|
| 23 |
+
pyarrow==15.0.0
|
| 24 |
+
pydeck==0.8.1b0
|
| 25 |
+
Pygments==2.17.2
|
| 26 |
+
pytesseract==0.3.10
|
| 27 |
+
python-dateutil==2.8.2
|
| 28 |
+
pytz==2024.1
|
| 29 |
+
referencing==0.33.0
|
| 30 |
+
requests==2.31.0
|
| 31 |
+
rich==13.7.0
|
| 32 |
+
rpds-py==0.18.0
|
| 33 |
+
six==1.16.0
|
| 34 |
+
smmap==5.0.1
|
| 35 |
+
streamlit==1.31.1
|
| 36 |
+
tenacity==8.2.3
|
| 37 |
+
toml==0.10.2
|
| 38 |
+
toolz==0.12.1
|
| 39 |
+
tornado==6.4
|
| 40 |
+
typing_extensions==4.9.0
|
| 41 |
+
tzdata==2024.1
|
| 42 |
+
tzlocal==5.2
|
| 43 |
+
urllib3==2.2.1
|
| 44 |
+
validators==0.22.0
|
| 45 |
+
zipp==3.17.0
|