handwritten-notes-ocr / streamlit_app.py
lakshmi-charan's picture
Upload streamlit_app.py
2b2caae verified
raw
history blame contribute delete
787 Bytes
import streamlit as st
from PIL import Image
from src.infer import recognize_image
st.set_page_config(page_title="Handwritten Notes OCR", layout="centered")
st.title("๐Ÿ“ Handwritten Notes Recognition (Deep Learning)")
st.write("Upload a handwritten line image and get recognized text.")
uploaded = st.file_uploader("Upload an image (jpg/png)", type=["jpg", "jpeg", "png"])
if uploaded:
img = Image.open(uploaded).convert("RGB")
st.image(img, caption="Uploaded image", use_container_width=True)
if st.button("Recognize Text"):
with st.spinner("Recognizing..."):
pred = recognize_image(img, ckpt_path="models/best.pt", device="cpu")
st.subheader("Prediction")
st.code(pred if pred else "(empty)", language="text")