import cv2 import pytesseract import streamlit as st import numpy as np def main(): st.set_page_config(page_title='Order ID Finder', layout='wide', page_icon='https://example.com/favicon.ico') st.title('Order ID Finder') st.image('https://seeklogo.com/images/S/streamlit-logo-1A3B208AE4-seeklogo.com.png', width=200) st.write('This app helps you find the order ID from an image of customized jewellery.') with st.sidebar: st.write('## Input') uploaded_file = st.file_uploader('Upload the image file (PNG or JPG)', type=['png', 'jpg'], help='Upload an image of customized jewellery') input_file = st.file_uploader('Upload the input file (TXT)', type=['txt'], help='Upload a TXT file that contains a list of order IDs, names, and font types') if st.button('Find Order ID') and uploaded_file and input_file: with st.spinner('Processing image...'): 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() found = False for line in lines: order_id, name, font = line.strip().split(',') if name.strip() in text: st.success(f'Order ID: {order_id}') found = True break if not found: st.error('Could not find the order ID in the image. Please try again with a different image or input file.') st.write('') st.write('') st.write('') st.image('https://www.canpackmachinery.com/wp-content/uploads/2018/03/Footer-Background-01-1.png', width=600) st.write('Contact us: contact@example.com') st.write('Follow us on social media: @example') if __name__ == '__main__': main()