tharu22 commited on
Commit
7f64752
Β·
1 Parent(s): b05f325
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -38,7 +38,7 @@ def get_image_embedding(image):
38
  return embedding
39
 
40
  # βœ… Function to Query Pinecone and Fetch Similar Images
41
- def search_similar_images(embedding, top_k=10):
42
  results = unsplash_index.query(
43
  vector=embedding,
44
  top_k=top_k,
@@ -70,7 +70,7 @@ if st.button("πŸ” Search by Text"):
70
 
71
  st.write(f"**Photo ID**: {photo_id} | **Similarity Score**: {score:.4f}")
72
  if url:
73
- st.image(url, caption=f"Photo ID: {photo_id}", use_column_width=True)
74
  else:
75
  st.warning(f"Image URL not found for Photo ID: {photo_id}")
76
  else:
@@ -82,7 +82,7 @@ uploaded_file = st.file_uploader("Upload an image...", type=["jpg", "png", "jpeg
82
 
83
  if uploaded_file:
84
  image = Image.open(uploaded_file).convert("RGB")
85
- st.image(image, caption="Uploaded Image", use_column_width=True)
86
 
87
  if st.button("πŸ” Search by Image"):
88
  with st.spinner("Generating embedding..."):
@@ -99,7 +99,7 @@ if uploaded_file:
99
 
100
  st.write(f"**Photo ID**: {photo_id} | **Similarity Score**: {score:.4f}")
101
  if url:
102
- st.image(url, caption=f"Photo ID: {photo_id}", use_column_width=True)
103
  else:
104
  st.warning(f"Image URL not found for Photo ID: {photo_id}")
105
 
 
38
  return embedding
39
 
40
  # βœ… Function to Query Pinecone and Fetch Similar Images
41
+ def search_similar_images(embedding, top_k=15):
42
  results = unsplash_index.query(
43
  vector=embedding,
44
  top_k=top_k,
 
70
 
71
  st.write(f"**Photo ID**: {photo_id} | **Similarity Score**: {score:.4f}")
72
  if url:
73
+ st.image(url, caption=f"Photo ID: {photo_id}", use_container_width=True)
74
  else:
75
  st.warning(f"Image URL not found for Photo ID: {photo_id}")
76
  else:
 
82
 
83
  if uploaded_file:
84
  image = Image.open(uploaded_file).convert("RGB")
85
+ st.image(image, caption="Uploaded Image", use_container_width=True)
86
 
87
  if st.button("πŸ” Search by Image"):
88
  with st.spinner("Generating embedding..."):
 
99
 
100
  st.write(f"**Photo ID**: {photo_id} | **Similarity Score**: {score:.4f}")
101
  if url:
102
+ st.image(url, caption=f"Photo ID: {photo_id}", use_container_width=True)
103
  else:
104
  st.warning(f"Image URL not found for Photo ID: {photo_id}")
105