File size: 580 Bytes
92af8f1
 
35030a7
48a6369
92af8f1
48a6369
35030a7
92af8f1
 
35030a7
dd9a8c6
92af8f1
35030a7
48a6369
35030a7
48a6369
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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}")