leedoming commited on
Commit
7cd611a
·
verified ·
1 Parent(s): c771084

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -113,7 +113,7 @@ def detect_clothing(image):
113
  for detection in detections:
114
  x1, y1, x2, y2, conf, cls = detection
115
  category = yolo_model.names[int(cls)]
116
- if category in ['top', 'bottom', 'hat', 'shoes']: # Add more categories as needed
117
  categories.append({
118
  'category': category,
119
  'bbox': [int(x1), int(y1), int(x2), int(y2)],
@@ -146,6 +146,7 @@ if search_type == "Image URL":
146
  if st.button("Search Similar Items"):
147
  selected_detection = next(d for d in detections if f"{d['category']} (Confidence: {d['confidence']:.2f})" == selected_category)
148
  cropped_image = crop_image(query_image, selected_detection['bbox'])
 
149
  query_embedding = get_image_embedding(cropped_image)
150
  similar_images = find_similar_images(query_embedding)
151
 
 
113
  for detection in detections:
114
  x1, y1, x2, y2, conf, cls = detection
115
  category = yolo_model.names[int(cls)]
116
+ if category in ['sunglass','hat','jacket','shirt','pants','shorts','skirt','dress','bag','shoe']:
117
  categories.append({
118
  'category': category,
119
  'bbox': [int(x1), int(y1), int(x2), int(y2)],
 
146
  if st.button("Search Similar Items"):
147
  selected_detection = next(d for d in detections if f"{d['category']} (Confidence: {d['confidence']:.2f})" == selected_category)
148
  cropped_image = crop_image(query_image, selected_detection['bbox'])
149
+ st.image(cropped_image, caption="Cropped Image", use_column_width=True)
150
  query_embedding = get_image_embedding(cropped_image)
151
  similar_images = find_similar_images(query_embedding)
152