Spaces:
Runtime error
Runtime error
Anusha806
commited on
Commit
·
58848d2
1
Parent(s):
c1181ca
commit25
Browse files
app.py
CHANGED
|
@@ -692,11 +692,13 @@ custom_css = """
|
|
| 692 |
margin-bottom: 4px !important;
|
| 693 |
}
|
| 694 |
|
|
|
|
| 695 |
.gr-gallery-item {
|
| 696 |
-
|
| 697 |
-
max-width:
|
|
|
|
| 698 |
height: auto !important;
|
| 699 |
-
margin:
|
| 700 |
}
|
| 701 |
|
| 702 |
.gr-gallery-item img {
|
|
@@ -705,19 +707,11 @@ custom_css = """
|
|
| 705 |
object-fit: cover !important;
|
| 706 |
}
|
| 707 |
|
|
|
|
| 708 |
@media (max-width: 768px) {
|
| 709 |
-
.gr-column {
|
| 710 |
-
width: 100% !important;
|
| 711 |
-
flex: 100% !important;
|
| 712 |
-
}
|
| 713 |
-
|
| 714 |
-
.search-btn {
|
| 715 |
-
font-size: 16px;
|
| 716 |
-
padding: 10px;
|
| 717 |
-
}
|
| 718 |
-
|
| 719 |
.gr-gallery-item {
|
| 720 |
-
|
|
|
|
| 721 |
}
|
| 722 |
}
|
| 723 |
"""
|
|
@@ -727,25 +721,14 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 727 |
|
| 728 |
with gr.Row(equal_height=True):
|
| 729 |
with gr.Column(scale=5, elem_classes="query-slider"):
|
| 730 |
-
query = gr.Textbox(
|
| 731 |
-
label="Enter your fashion search query",
|
| 732 |
-
placeholder="e.g., black sneakers for women"
|
| 733 |
-
)
|
| 734 |
alpha = gr.Slider(0, 1, value=0.5, label="Hybrid Weight (alpha: 0=sparse, 1=dense)")
|
| 735 |
-
gender_dropdown = gr.Dropdown(
|
| 736 |
-
["", "Men", "Women", "Boys", "Girls", "Kids", "Unisex"],
|
| 737 |
-
label="Gender Filter (optional)"
|
| 738 |
-
)
|
| 739 |
with gr.Column(scale=1):
|
| 740 |
-
image_input = gr.Image(
|
| 741 |
-
type="pil",
|
| 742 |
-
label="Upload an image (optional)",
|
| 743 |
-
sources=["upload", "clipboard"],
|
| 744 |
-
height="auto"
|
| 745 |
-
)
|
| 746 |
|
| 747 |
search_btn = gr.Button("Search", elem_classes="search-btn")
|
| 748 |
-
gallery = gr.Gallery(label="Search Results", columns=
|
| 749 |
load_more_btn = gr.Button("Load More")
|
| 750 |
|
| 751 |
search_offset = gr.State(0)
|
|
@@ -771,11 +754,9 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 771 |
seen_ids = {r[1] for r in results}
|
| 772 |
return results, end, q, uploaded_image, gender_override, results, seen_ids
|
| 773 |
|
| 774 |
-
search_btn.click(
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
outputs=[gallery, search_offset, current_query, current_image, current_gender, shown_results, shown_ids]
|
| 778 |
-
)
|
| 779 |
|
| 780 |
def load_more_fn(a, offset, q, img, gender_ui, prev_results, prev_ids):
|
| 781 |
start = offset
|
|
@@ -802,12 +783,11 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 802 |
|
| 803 |
return combined, end, combined, updated_ids
|
| 804 |
|
| 805 |
-
load_more_btn.click(
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
outputs=[gallery, search_offset, shown_results, shown_ids]
|
| 809 |
-
)
|
| 810 |
|
| 811 |
gr.Markdown("🧠 Powered by OpenAI + Hybrid AI Fashion Search")
|
| 812 |
|
| 813 |
demo.launch()
|
|
|
|
|
|
| 692 |
margin-bottom: 4px !important;
|
| 693 |
}
|
| 694 |
|
| 695 |
+
/* Default: 6 per row */
|
| 696 |
.gr-gallery-item {
|
| 697 |
+
flex: 1 1 calc(16.66% - 10px); /* 6 per row with some gap */
|
| 698 |
+
max-width: calc(16.66% - 10px);
|
| 699 |
+
box-sizing: border-box;
|
| 700 |
height: auto !important;
|
| 701 |
+
margin-bottom: 10px;
|
| 702 |
}
|
| 703 |
|
| 704 |
.gr-gallery-item img {
|
|
|
|
| 707 |
object-fit: cover !important;
|
| 708 |
}
|
| 709 |
|
| 710 |
+
/* On small screens: 3 per row */
|
| 711 |
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 712 |
.gr-gallery-item {
|
| 713 |
+
flex: 1 1 calc(33.33% - 10px); /* 3 per row */
|
| 714 |
+
max-width: calc(33.33% - 10px);
|
| 715 |
}
|
| 716 |
}
|
| 717 |
"""
|
|
|
|
| 721 |
|
| 722 |
with gr.Row(equal_height=True):
|
| 723 |
with gr.Column(scale=5, elem_classes="query-slider"):
|
| 724 |
+
query = gr.Textbox(label="Enter your fashion search query", placeholder="e.g., black sneakers for women")
|
|
|
|
|
|
|
|
|
|
| 725 |
alpha = gr.Slider(0, 1, value=0.5, label="Hybrid Weight (alpha: 0=sparse, 1=dense)")
|
| 726 |
+
gender_dropdown = gr.Dropdown(["", "Men", "Women", "Boys", "Girls", "Kids", "Unisex"], label="Gender Filter (optional)")
|
|
|
|
|
|
|
|
|
|
| 727 |
with gr.Column(scale=1):
|
| 728 |
+
image_input = gr.Image(type="pil", label="Upload an image (optional)", sources=["upload", "clipboard"], height=256)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 729 |
|
| 730 |
search_btn = gr.Button("Search", elem_classes="search-btn")
|
| 731 |
+
gallery = gr.Gallery(label="Search Results", columns=6, height=None, allow_preview=True) # 'columns=6' ignored due to CSS override
|
| 732 |
load_more_btn = gr.Button("Load More")
|
| 733 |
|
| 734 |
search_offset = gr.State(0)
|
|
|
|
| 754 |
seen_ids = {r[1] for r in results}
|
| 755 |
return results, end, q, uploaded_image, gender_override, results, seen_ids
|
| 756 |
|
| 757 |
+
search_btn.click(unified_search,
|
| 758 |
+
inputs=[query, image_input, alpha, search_offset, gender_dropdown],
|
| 759 |
+
outputs=[gallery, search_offset, current_query, current_image, current_gender, shown_results, shown_ids])
|
|
|
|
|
|
|
| 760 |
|
| 761 |
def load_more_fn(a, offset, q, img, gender_ui, prev_results, prev_ids):
|
| 762 |
start = offset
|
|
|
|
| 783 |
|
| 784 |
return combined, end, combined, updated_ids
|
| 785 |
|
| 786 |
+
load_more_btn.click(load_more_fn,
|
| 787 |
+
inputs=[alpha, search_offset, current_query, current_image, current_gender, shown_results, shown_ids],
|
| 788 |
+
outputs=[gallery, search_offset, shown_results, shown_ids])
|
|
|
|
|
|
|
| 789 |
|
| 790 |
gr.Markdown("🧠 Powered by OpenAI + Hybrid AI Fashion Search")
|
| 791 |
|
| 792 |
demo.launch()
|
| 793 |
+
|