import streamlit as st import easyocr from PIL import Image import numpy as np def extract_text(image_path, lang='uz'): reader = easyocr.Reader([lang]) results = reader.readtext(np.array(image_path)) all_text = '' confidences = [] for (bbox, text, prob) in results: all_text += ' ' + text confidences.append(prob) final_confidence = sum(confidences) / len(confidences) if confidences else 0 return all_text, final_confidence st.title('Rasmdan matnni chiqarish') uploaded_file = st.file_uploader("Rasmni tanlang...", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: image = Image.open(uploaded_file) st.image(image, caption='Yuklangan rasm', use_column_width=True) st.write("") st.write("Ishlanmoqda...") extracted_text, confidence = extract_text(image, 'uz') # Assuming 'tjk' works for your needs, replace or adjust as needed st.write("Olingan matn") st.text_area("Natija", extracted_text, height=150) st.write(f"Aniqligi: {confidence*100:.2f}%")