import streamlit as st import pickle as pkl from PIL import Image from sklearn.neighbors import NearestNeighbors from tensorflow.keras.models import load_model from tensorflow.keras.applications.resnet50 import preprocess_input from tensorflow.keras.preprocessing import image import os from numpy.linalg import norm import numpy as np # Load necessary files and model filenames = pkl.load(open('filenames2.pkl', 'rb')) Image_features = pkl.load(open('Images_features2.pkl', 'rb')) neighbors = NearestNeighbors(n_neighbors=6, algorithm='brute', metric='euclidean') neighbors.fit(Image_features) model = load_model('model.h5') # Feature extraction function def extract_features_from_images(image_path, model): img = image.load_img(image_path, target_size=(224, 224)) img_array = image.img_to_array(img) img_expand_dim = np.expand_dims(img_array, axis=0) img_preprocess = preprocess_input(img_expand_dim) result = model.predict(img_preprocess).flatten() norm_result = result / norm(result) return norm_result # Custom CSS for background and title st.markdown( """ """, unsafe_allow_html=True, ) # Streamlit UI st.markdown('