Upload Main Files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Images_features2.pkl +3 -0
- app.py +72 -0
- filenames2.pkl +3 -0
- images/10000.jpg +0 -0
- images/10001.jpg +0 -0
- images/10002.jpg +0 -0
- images/10003.jpg +0 -0
- images/10004.jpg +0 -0
- images/10005.jpg +0 -0
- images/10006.jpg +0 -0
- images/10007.jpg +0 -0
- images/10008.jpg +0 -0
- images/10009.jpg +0 -0
- images/10010.jpg +0 -0
- images/10011.jpg +0 -0
- images/10012.jpg +0 -0
- images/10013.jpg +0 -0
- images/10014.jpg +0 -0
- images/10015.jpg +0 -0
- images/10016.jpg +0 -0
- images/10017.jpg +0 -0
- images/10018.jpg +0 -0
- images/10019.jpg +0 -0
- images/10020.jpg +0 -0
- images/10021.jpg +0 -0
- images/10022.jpg +0 -0
- images/10023.jpg +0 -0
- images/10024.jpg +0 -0
- images/10025.jpg +0 -0
- images/10026.jpg +0 -0
- images/10027.jpg +0 -0
- images/10028.jpg +0 -0
- images/10029.jpg +0 -0
- images/10030.jpg +0 -0
- images/10031.jpg +0 -0
- images/10032.jpg +0 -0
- images/10033.jpg +0 -0
- images/10034.jpg +0 -0
- images/10035.jpg +0 -0
- images/10037.jpg +0 -0
- images/10039.jpg +0 -0
- images/10040.jpg +0 -0
- images/10041.jpg +0 -0
- images/10042.jpg +0 -0
- images/10043.jpg +0 -0
- images/10044.jpg +0 -0
- images/10045.jpg +0 -0
- images/10046.jpg +0 -0
- images/10047.jpg +0 -0
- images/10048.jpg +0 -0
Images_features2.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a707cde72a062b48a907de8ed64aa0667d879259f9f0b8f1ec8ed653c6ce9f4
|
| 3 |
+
size 365621870
|
app.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pickle as pkl
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from sklearn.neighbors import NearestNeighbors
|
| 5 |
+
from tensorflow.keras.models import load_model
|
| 6 |
+
from tensorflow.keras.applications.resnet50 import preprocess_input
|
| 7 |
+
from tensorflow.keras.preprocessing import image
|
| 8 |
+
import os
|
| 9 |
+
from numpy.linalg import norm
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
# Load necessary files and model
|
| 13 |
+
filenames = pkl.load(open('filenames2.pkl', 'rb'))
|
| 14 |
+
Image_features = pkl.load(open('Images_features2.pkl', 'rb'))
|
| 15 |
+
neighbors = NearestNeighbors(n_neighbors=6, algorithm='brute', metric='euclidean')
|
| 16 |
+
neighbors.fit(Image_features)
|
| 17 |
+
model = load_model('model.h5')
|
| 18 |
+
|
| 19 |
+
# Feature extraction function
|
| 20 |
+
def extract_features_from_images(image_path, model):
|
| 21 |
+
img = image.load_img(image_path, target_size=(224, 224))
|
| 22 |
+
img_array = image.img_to_array(img)
|
| 23 |
+
img_expand_dim = np.expand_dims(img_array, axis=0)
|
| 24 |
+
img_preprocess = preprocess_input(img_expand_dim)
|
| 25 |
+
result = model.predict(img_preprocess).flatten()
|
| 26 |
+
norm_result = result / norm(result)
|
| 27 |
+
return norm_result
|
| 28 |
+
|
| 29 |
+
# Custom CSS for background and title
|
| 30 |
+
st.markdown(
|
| 31 |
+
"""
|
| 32 |
+
<style>
|
| 33 |
+
body {
|
| 34 |
+
background-color: #f0f8ff; /* Soft light blue background */
|
| 35 |
+
}
|
| 36 |
+
.title {
|
| 37 |
+
color: #1f7a8c; /* Teal color */
|
| 38 |
+
font-family: 'Arial Black', sans-serif;
|
| 39 |
+
text-align: center;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
""",
|
| 43 |
+
unsafe_allow_html=True,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Streamlit UI
|
| 47 |
+
st.markdown('<h1 class="title">Fashion Deep Learning Classification 👗</h1>', unsafe_allow_html=True)
|
| 48 |
+
st.write('Upload a clothing image, and the model recommends similar products.')
|
| 49 |
+
|
| 50 |
+
file = st.file_uploader('Upload an Image', type=['jpg', 'jpeg', 'png'])
|
| 51 |
+
|
| 52 |
+
if file is not None:
|
| 53 |
+
# Display uploaded image with reduced size
|
| 54 |
+
img = Image.open(file)
|
| 55 |
+
st.image(img, caption='Uploaded Image', width=200, use_column_width=False)
|
| 56 |
+
|
| 57 |
+
# Extract features from the uploaded image
|
| 58 |
+
input_image = extract_features_from_images(file, model)
|
| 59 |
+
|
| 60 |
+
# Get recommendations
|
| 61 |
+
distance, indices = neighbors.kneighbors([input_image])
|
| 62 |
+
st.subheader("Recommended Products:")
|
| 63 |
+
|
| 64 |
+
# Display recommendations in a grid layout
|
| 65 |
+
cols = st.columns(3) # 3 images per row
|
| 66 |
+
for i, idx in enumerate(indices[0]):
|
| 67 |
+
product_path = filenames[idx]
|
| 68 |
+
product_image = Image.open(product_path)
|
| 69 |
+
|
| 70 |
+
# Assign columns dynamically
|
| 71 |
+
with cols[i % 3]:
|
| 72 |
+
st.image(product_image, caption=f"Product {i + 1}", use_column_width=True)
|
filenames2.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f7076602ce29da942074fab43bd8af025e5f0f7fe3ec5b7ed0166bd15f8d212b
|
| 3 |
+
size 837463
|
images/10000.jpg
ADDED
|
images/10001.jpg
ADDED
|
images/10002.jpg
ADDED
|
images/10003.jpg
ADDED
|
images/10004.jpg
ADDED
|
images/10005.jpg
ADDED
|
images/10006.jpg
ADDED
|
images/10007.jpg
ADDED
|
images/10008.jpg
ADDED
|
images/10009.jpg
ADDED
|
images/10010.jpg
ADDED
|
images/10011.jpg
ADDED
|
images/10012.jpg
ADDED
|
images/10013.jpg
ADDED
|
images/10014.jpg
ADDED
|
images/10015.jpg
ADDED
|
images/10016.jpg
ADDED
|
images/10017.jpg
ADDED
|
images/10018.jpg
ADDED
|
images/10019.jpg
ADDED
|
images/10020.jpg
ADDED
|
images/10021.jpg
ADDED
|
images/10022.jpg
ADDED
|
images/10023.jpg
ADDED
|
images/10024.jpg
ADDED
|
images/10025.jpg
ADDED
|
images/10026.jpg
ADDED
|
images/10027.jpg
ADDED
|
images/10028.jpg
ADDED
|
images/10029.jpg
ADDED
|
images/10030.jpg
ADDED
|
images/10031.jpg
ADDED
|
images/10032.jpg
ADDED
|
images/10033.jpg
ADDED
|
images/10034.jpg
ADDED
|
images/10035.jpg
ADDED
|
images/10037.jpg
ADDED
|
images/10039.jpg
ADDED
|
images/10040.jpg
ADDED
|
images/10041.jpg
ADDED
|
images/10042.jpg
ADDED
|
images/10043.jpg
ADDED
|
images/10044.jpg
ADDED
|
images/10045.jpg
ADDED
|
images/10046.jpg
ADDED
|
images/10047.jpg
ADDED
|
images/10048.jpg
ADDED
|