Spaces:
Sleeping
Sleeping
compare to chicory-ui
Browse files
ui.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from utils import SafeProgress, format_categories_html
|
3 |
from embeddings import create_product_embeddings
|
4 |
from similarity import compute_similarities
|
|
|
5 |
|
6 |
# Global variable for embeddings
|
7 |
embeddings = {}
|
@@ -22,6 +23,10 @@ def categorize_products_from_text(product_text, top_n=5, confidence_threshold=0.
|
|
22 |
progress_tracker(0.1, desc="Generating product embeddings...")
|
23 |
products_embeddings = create_product_embeddings(product_names)
|
24 |
|
|
|
|
|
|
|
|
|
25 |
# Compute similarities
|
26 |
progress_tracker(0.6, desc="Computing similarities...")
|
27 |
all_similarities = compute_similarities(embeddings, products_embeddings)
|
@@ -36,7 +41,7 @@ def categorize_products_from_text(product_text, top_n=5, confidence_threshold=0.
|
|
36 |
if score >= confidence_threshold]
|
37 |
top_similarities = filtered_similarities[:top_n]
|
38 |
|
39 |
-
output_html += format_categories_html(product, top_similarities)
|
40 |
output_html += "<hr style='margin: 15px 0; border: 0; border-top: 1px solid #eee;'>"
|
41 |
|
42 |
output_html += "</div>"
|
@@ -67,6 +72,10 @@ def categorize_products_from_file(file, top_n=5, confidence_threshold=0.5, progr
|
|
67 |
progress_tracker(0.2, desc="Generating product embeddings...")
|
68 |
products_embeddings = create_product_embeddings(product_names)
|
69 |
|
|
|
|
|
|
|
|
|
70 |
# Compute similarities
|
71 |
progress_tracker(0.7, desc="Computing similarities...")
|
72 |
all_similarities = compute_similarities(embeddings, products_embeddings)
|
@@ -84,7 +93,7 @@ def categorize_products_from_file(file, top_n=5, confidence_threshold=0.5, progr
|
|
84 |
if score >= confidence_threshold]
|
85 |
top_similarities = filtered_similarities[:top_n]
|
86 |
|
87 |
-
output_html += format_categories_html(product, top_similarities)
|
88 |
output_html += "<hr style='margin: 15px 0; border: 0; border-top: 1px solid #eee;'>"
|
89 |
|
90 |
output_html += "</div>"
|
|
|
2 |
from utils import SafeProgress, format_categories_html
|
3 |
from embeddings import create_product_embeddings
|
4 |
from similarity import compute_similarities
|
5 |
+
from chicory_api import call_chicory_parser # Import the Chicory API function
|
6 |
|
7 |
# Global variable for embeddings
|
8 |
embeddings = {}
|
|
|
23 |
progress_tracker(0.1, desc="Generating product embeddings...")
|
24 |
products_embeddings = create_product_embeddings(product_names)
|
25 |
|
26 |
+
# Call Chicory Parser API
|
27 |
+
progress_tracker(0.5, desc="Calling Chicory Parser API...")
|
28 |
+
chicory_results = call_chicory_parser(product_names)
|
29 |
+
|
30 |
# Compute similarities
|
31 |
progress_tracker(0.6, desc="Computing similarities...")
|
32 |
all_similarities = compute_similarities(embeddings, products_embeddings)
|
|
|
41 |
if score >= confidence_threshold]
|
42 |
top_similarities = filtered_similarities[:top_n]
|
43 |
|
44 |
+
output_html += format_categories_html(product, top_similarities, chicory_result=chicory_results.get(product))
|
45 |
output_html += "<hr style='margin: 15px 0; border: 0; border-top: 1px solid #eee;'>"
|
46 |
|
47 |
output_html += "</div>"
|
|
|
72 |
progress_tracker(0.2, desc="Generating product embeddings...")
|
73 |
products_embeddings = create_product_embeddings(product_names)
|
74 |
|
75 |
+
# Call Chicory Parser API
|
76 |
+
progress_tracker(0.5, desc="Calling Chicory Parser API...")
|
77 |
+
chicory_results = call_chicory_parser(product_names)
|
78 |
+
|
79 |
# Compute similarities
|
80 |
progress_tracker(0.7, desc="Computing similarities...")
|
81 |
all_similarities = compute_similarities(embeddings, products_embeddings)
|
|
|
93 |
if score >= confidence_threshold]
|
94 |
top_similarities = filtered_similarities[:top_n]
|
95 |
|
96 |
+
output_html += format_categories_html(product, top_similarities, chicory_result=chicory_results.get(product))
|
97 |
output_html += "<hr style='margin: 15px 0; border: 0; border-top: 1px solid #eee;'>"
|
98 |
|
99 |
output_html += "</div>"
|