import streamlit as st import pandas as pd import matplotlib.pyplot as plt import numpy as np from PIL import Image,ImageOps import numpy as np import random import cv2 import tensorflow as tf from tensorflow import keras from keras.models import load_model import time # import mysql.connector import process_input_pipeline as pp import img_extractor from process_input_pipeline import ImageResizer, ContrastEnhancer # added for inception concat from sklearn.pipeline import make_pipeline from sklearn.base import BaseEstimator, TransformerMixin import combined_model cm = combined_model.build_regression_model() cm.load_weights(r"F:\python\web_streamlit\ALL_IN_ONE\model_weights\model_weights\combined_weights_7_epoch_third_acc.h5") roi=img_extractor.RoiExtractor() def process_image(img, img_size=(224, 224)): try: new_size=(299,299) resized_img = img.resize(new_size, Image.BICUBIC) img_array=np.array(resized_img) clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(64, 64)) cl1 = clahe.apply(img_array) cl2=cv2.cvtColor(cl1,cv2.COLOR_GRAY2BGR) return cl2 except Exception as e: st.error(f"Error processing image: {e}") return None def predict(img_data_c,img_data_m, gender): try: if gender == 'Female': # gender_input = np.array([0]) gender_input=0 elif gender == 'Male': gender_input = 1 pred =cm.predict([np.array([img_data_c]),np.array([img_data_m]), np.array([gender_input])]) # pred = model.predict(img_data) return pred except Exception as e: st.error(f"Error predicting bone age: {e}") return None