import requests from PIL import Image import streamlit as st from transformers import pipeline pipe = pipeline("image-to-text", model="microsoft/trocr-large-printed") st.title("Duh!") # load image from the IAM dataset url = "https://parivahan.gov.in/rcdlstatus/DispplayCaptcha?txtp_cd=1&bkgp_cd=2&noise_cd=2&gimp_cd=3&txtp_length=5&pfdrid_c=true?1429026471&pfdrid_c=true" image = Image.open(requests.get(url, stream=True).raw) col1, col2 = st.columns(2) predictions = pipeline(image) col1.image(image, use_column_width=True) col2.subheader(f"Detected Text: {predictions}")