Update pages/3_Sketch_To_Image.py
Browse files191 unmodified lines19219319419519619719872 unmodified lines271272273273274275276274275276277278279280281282283284285286287288289290191 unmodified linesfrom facenet_pytorch import MTCNNimport matplotlib.pyplot as pltfrom image_search import query_custom_model # your custom model logicfrom image_search import query_by_image, load_custom_model
# 📍 Path settingsDATASET_DIR = "flickr8k/Flickr8k_Dataset"72 unmodified lines st.image(generated_image.resize((784, 784))) else: st.warning(f"⚠️ Pix2Pix skipped (face count ≠ 1 or face < {FACE_AREA_THRESHOLD*100:.0f}%). Showing similar images.") top_images = query_custom_model(image=sketch, k=5)
st.subheader("Top 5 Similar Images (Custom Model)") st.image(top_images, width=150, caption=[f"Match {i+1}" for i in range(len(top_images))]) # top_images = query_custom_model(image=sketch, k=5)
# st.subheader("Top 5 Similar Images (Custom Model)") # st.image(top_images, width=150, caption=[f"Match {i+1}" for i in range(len(top_images))]) # Save the uploaded sketch temporarily temp_path = "temp_sketch.jpg" sketch.save(temp_path)
# results = query_by_image(temp_path, nn_model, image_paths)
nn_model, _, image_paths = load_custom_model() results = query_by_image(temp_path, nn_model, image_paths) st.subheader("Similar Images Using Custom Model") for i, path in enumerate(results): st.markdown(f"🔗 **Match {i+1}:** [{os.path.basename(path)}]({path})") if os.path.exists(temp_path): os.remove(temp_path)pages/3_Sketch_To_Image.py+18-4