import cv2 import pytesseract import streamlit as st import numpy as np def main(): st.title('Order ID Finder') uploaded_file = st.file_uploader('Upload an image', type=['png', 'jpg']) input_file = st.file_uploader('Upload the input file', type=['txt']) if uploaded_file and input_file: img = cv2.imdecode(np.fromstring(uploaded_file.read(), np.uint8), 1) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) text = pytesseract.image_to_string(gray) with input_file as file: file_contents = file.read() lines = file_contents.decode().splitlines() for line in lines: order_id, name, font = line.strip().split(',') if name.strip() in text: st.success(f'Order ID: {order_id}') break if __name__ == '__main__': main()