Spaces:
Sleeping
Sleeping
Commit
·
e560475
1
Parent(s):
d3676c7
Add files and folders to G-FASHION
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +7 -35
- README.md +24 -5
- app.py +80 -0
- feature_list.pkl +3 -0
- filepath.pkl +3 -0
- images1/10000.jpg +3 -0
- images1/10001.jpg +3 -0
- images1/10002.jpg +3 -0
- images1/10003.jpg +3 -0
- images1/10004.jpg +3 -0
- images1/10005.jpg +3 -0
- images1/10006.jpg +3 -0
- images1/10007.jpg +3 -0
- images1/10008.jpg +3 -0
- images1/10009.jpg +3 -0
- images1/10010.jpg +3 -0
- images1/10011.jpg +3 -0
- images1/10012.jpg +3 -0
- images1/10013.jpg +3 -0
- images1/10014.jpg +3 -0
- images1/10015.jpg +3 -0
- images1/10016.jpg +3 -0
- images1/10017.jpg +3 -0
- images1/10018.jpg +3 -0
- images1/10019.jpg +3 -0
- images1/10020.jpg +3 -0
- images1/10021.jpg +3 -0
- images1/10022.jpg +3 -0
- images1/10023.jpg +3 -0
- images1/10024.jpg +3 -0
- images1/10025.jpg +3 -0
- images1/10026.jpg +3 -0
- images1/10027.jpg +3 -0
- images1/10028.jpg +3 -0
- images1/10029.jpg +3 -0
- images1/10030.jpg +3 -0
- images1/10031.jpg +3 -0
- images1/10032.jpg +3 -0
- images1/10033.jpg +3 -0
- images1/10034.jpg +3 -0
- images1/10035.jpg +3 -0
- images1/10037.jpg +3 -0
- images1/10039.jpg +3 -0
- images1/10040.jpg +3 -0
- images1/10041.jpg +3 -0
- images1/10042.jpg +3 -0
- images1/10043.jpg +3 -0
- images1/10044.jpg +3 -0
- images1/10045.jpg +3 -0
- images1/10046.jpg +3 -0
.gitattributes
CHANGED
@@ -1,35 +1,7 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
feature_list.pkl filter=lfs diff=lfs merge=lfs -text
|
2 |
+
images1/* filter=lfs diff=lfs merge=lfs -text
|
3 |
+
images2/* filter=lfs diff=lfs merge=lfs -text
|
4 |
+
images3/* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
images4/* filter=lfs diff=lfs merge=lfs -text
|
6 |
+
images5/* filter=lfs diff=lfs merge=lfs -text
|
7 |
+
filepath.pkl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,13 +1,32 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
-
sdk_version: 1.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Goody Goody Fashion Store
|
3 |
+
emoji: 🏆
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: indigo
|
6 |
sdk: streamlit
|
7 |
+
sdk_version: 1.26.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
+
"FASHION RECOMMENDER SYSTEM"
|
14 |
+
|
15 |
+
Game Plan Image Dataset: Start with a dataset containing 44,000 fashion images.
|
16 |
+
|
17 |
+
Pre-trained Model - ResNet-50: Utilize the pre-trained ResNet-50 model, a convolutional neural network (CNN) trained on a large dataset for image classification tasks.
|
18 |
+
|
19 |
+
Extracting Embeddings: Pass each image through the ResNet-50 model to extract feature embeddings. The output will be a numerical vector (embedding) that represents the image's features
|
20 |
+
|
21 |
+
Embedding Extraction Function: Define a function to extract embeddings using the pre-trained ResNet-50 model. This function takes an image as input and returns the corresponding feature embedding.
|
22 |
+
|
23 |
+
Search for Similar Embeddings: When a new image is presented to the system: Use the embedding extraction function to obtain the embedding for the new image. Compare this embedding with the embeddings of all images in the dataset.
|
24 |
+
|
25 |
+
Similarity Ranking: Calculate the similarity between the embeddings (e.g., cosine similarity). Rank the images based on their similarity to the embedding of the new image.
|
26 |
+
|
27 |
+
Top 5 Similar Images: Select the top 5 images with the highest similarity scores.
|
28 |
+
|
29 |
+
Display Recommendations: Display the top 5 images as fashion recommendations for the given new image.
|
30 |
+
|
31 |
+
|
32 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
import pickle
|
5 |
+
import os
|
6 |
+
import tensorflow
|
7 |
+
from tensorflow.keras.preprocessing import image
|
8 |
+
from tensorflow.keras.layers import GlobalMaxPooling2D, Dense
|
9 |
+
from sklearn.neighbors import NearestNeighbors
|
10 |
+
from numpy.linalg import norm
|
11 |
+
from classification_models.tfkeras import Classifiers
|
12 |
+
|
13 |
+
filenames = pickle.load(open('filepath.pkl','rb'))
|
14 |
+
feature_list = pickle.load(open('feature_list.pkl','rb'))
|
15 |
+
feature_list = np.array(feature_list)
|
16 |
+
# Get the ResNeXt model
|
17 |
+
ResNeXt50, preprocess_input = Classifiers.get('resnext50')
|
18 |
+
# create a model instance
|
19 |
+
model = ResNeXt50(include_top=False, input_shape=(224, 224, 3), weights='imagenet')
|
20 |
+
model.trainable = False
|
21 |
+
model = tensorflow.keras.Sequential([model,GlobalMaxPooling2D()])
|
22 |
+
|
23 |
+
st.title('goody goody fashion store')
|
24 |
+
|
25 |
+
def save_uploaded_file(uploaded_file):
|
26 |
+
try:
|
27 |
+
# Check if the 'uploads' directory exists. If not, create it.
|
28 |
+
if not os.path.exists('uploads'):
|
29 |
+
os.makedirs('uploads')
|
30 |
+
|
31 |
+
with open(os.path.join('uploads',uploaded_file.name),'wb') as f:
|
32 |
+
f.write(uploaded_file.getbuffer())
|
33 |
+
return 1
|
34 |
+
except Exception as e:
|
35 |
+
# Print the exception message
|
36 |
+
print(f"Error in save_uploaded_file: {e}")
|
37 |
+
return 0
|
38 |
+
|
39 |
+
def feature_extraction(img_path,model):
|
40 |
+
img = image.load_img(img_path, target_size=(224, 224))
|
41 |
+
img_array = image.img_to_array(img)
|
42 |
+
expanded_img_array = np.expand_dims(img_array, axis=0)
|
43 |
+
preprocessed_img = preprocess_input(expanded_img_array)
|
44 |
+
result = model.predict(preprocessed_img).flatten()
|
45 |
+
normalized_result = result / norm(result)
|
46 |
+
|
47 |
+
return normalized_result
|
48 |
+
|
49 |
+
def recommend(features,feature_list):
|
50 |
+
neighbors = NearestNeighbors(n_neighbors=6, algorithm='brute', metric='cosine')
|
51 |
+
neighbors.fit(feature_list)
|
52 |
+
|
53 |
+
distances, indices = neighbors.kneighbors([features])
|
54 |
+
|
55 |
+
return indices
|
56 |
+
|
57 |
+
uploaded_file = st.file_uploader("Choose an image")
|
58 |
+
if uploaded_file is not None:
|
59 |
+
if save_uploaded_file(uploaded_file):
|
60 |
+
display_image = Image.open(uploaded_file)
|
61 |
+
st.image(display_image)
|
62 |
+
features = feature_extraction(os.path.join("uploads",uploaded_file.name),model)
|
63 |
+
indices = recommend(features,feature_list)
|
64 |
+
col1,col2,col3,col4,col5 = st.columns(5)
|
65 |
+
|
66 |
+
# Add a print statement to print the file path
|
67 |
+
print(f"File path: {filenames[indices[0][0]]}")
|
68 |
+
|
69 |
+
with col1:
|
70 |
+
st.image(r'{}'.format(filenames[indices[0][0]]))
|
71 |
+
with col2:
|
72 |
+
st.image(r'{}'.format(filenames[indices[0][1]]))
|
73 |
+
with col3:
|
74 |
+
st.image(r'{}'.format(filenames[indices[0][2]]))
|
75 |
+
with col4:
|
76 |
+
st.image(r'{}'.format(filenames[indices[0][3]]))
|
77 |
+
with col5:
|
78 |
+
st.image(r'{}'.format(filenames[indices[0][4]]))
|
79 |
+
else:
|
80 |
+
st.header("Some error occured in file upload")
|
feature_list.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ba82b5128afe62827a31739b85bcd15bc5174b58f563bed06858dcb698c7d0d
|
3 |
+
size 365621870
|
filepath.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8a6d99cd8cc6f4fccfa30b8c4527458f164c9d4ef560955d226dceb5e3ddf637
|
3 |
+
size 881913
|
images1/10000.jpg
ADDED
![]() |
Git LFS Details
|
images1/10001.jpg
ADDED
![]() |
Git LFS Details
|
images1/10002.jpg
ADDED
![]() |
Git LFS Details
|
images1/10003.jpg
ADDED
![]() |
Git LFS Details
|
images1/10004.jpg
ADDED
![]() |
Git LFS Details
|
images1/10005.jpg
ADDED
![]() |
Git LFS Details
|
images1/10006.jpg
ADDED
![]() |
Git LFS Details
|
images1/10007.jpg
ADDED
![]() |
Git LFS Details
|
images1/10008.jpg
ADDED
![]() |
Git LFS Details
|
images1/10009.jpg
ADDED
![]() |
Git LFS Details
|
images1/10010.jpg
ADDED
![]() |
Git LFS Details
|
images1/10011.jpg
ADDED
![]() |
Git LFS Details
|
images1/10012.jpg
ADDED
![]() |
Git LFS Details
|
images1/10013.jpg
ADDED
![]() |
Git LFS Details
|
images1/10014.jpg
ADDED
![]() |
Git LFS Details
|
images1/10015.jpg
ADDED
![]() |
Git LFS Details
|
images1/10016.jpg
ADDED
![]() |
Git LFS Details
|
images1/10017.jpg
ADDED
![]() |
Git LFS Details
|
images1/10018.jpg
ADDED
![]() |
Git LFS Details
|
images1/10019.jpg
ADDED
![]() |
Git LFS Details
|
images1/10020.jpg
ADDED
![]() |
Git LFS Details
|
images1/10021.jpg
ADDED
![]() |
Git LFS Details
|
images1/10022.jpg
ADDED
![]() |
Git LFS Details
|
images1/10023.jpg
ADDED
![]() |
Git LFS Details
|
images1/10024.jpg
ADDED
![]() |
Git LFS Details
|
images1/10025.jpg
ADDED
![]() |
Git LFS Details
|
images1/10026.jpg
ADDED
![]() |
Git LFS Details
|
images1/10027.jpg
ADDED
![]() |
Git LFS Details
|
images1/10028.jpg
ADDED
![]() |
Git LFS Details
|
images1/10029.jpg
ADDED
![]() |
Git LFS Details
|
images1/10030.jpg
ADDED
![]() |
Git LFS Details
|
images1/10031.jpg
ADDED
![]() |
Git LFS Details
|
images1/10032.jpg
ADDED
![]() |
Git LFS Details
|
images1/10033.jpg
ADDED
![]() |
Git LFS Details
|
images1/10034.jpg
ADDED
![]() |
Git LFS Details
|
images1/10035.jpg
ADDED
![]() |
Git LFS Details
|
images1/10037.jpg
ADDED
![]() |
Git LFS Details
|
images1/10039.jpg
ADDED
![]() |
Git LFS Details
|
images1/10040.jpg
ADDED
![]() |
Git LFS Details
|
images1/10041.jpg
ADDED
![]() |
Git LFS Details
|
images1/10042.jpg
ADDED
![]() |
Git LFS Details
|
images1/10043.jpg
ADDED
![]() |
Git LFS Details
|
images1/10044.jpg
ADDED
![]() |
Git LFS Details
|
images1/10045.jpg
ADDED
![]() |
Git LFS Details
|
images1/10046.jpg
ADDED
![]() |
Git LFS Details
|