Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from PIL import Image | |
| import pytesseract | |
| pytesseract.pytesseract.tesseract_cmd = "/opt/homebrew/bin/tesseract" | |
| def extract_text(image): | |
| try: | |
| text = pytesseract.image_to_string(image, lang='eng',config='--psm 1') | |
| return text | |
| except Exception as e: | |
| return str(e) | |
| def main(): | |
| st.title("Text Extraction from Image in English and Tamil") | |
| uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file) | |
| st.image(image, caption="Uploaded Image", use_column_width=True) | |
| text = extract_text(image) | |
| st.success("Text extracted successfully!") | |
| st.header("Extracted Text:") | |
| st.write(text) | |
| if __name__ == "__main__": | |
| main() | |