cabustillo13 commited on
Commit
e43c5ed
1 Parent(s): 3198d44

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from tools.extract_features import extract_features_image
4
+ from tools.search import search_similar_products
5
+ from tools.load_database import select_database
6
+
7
+ # Default values
8
+ MARCAS = ["Ninguno", "Zara", "Adidas", "Nike", "Puma", "Levi's", "Forever 21", "H&M", "Gap", "Converse", "Mango"]
9
+ PRENDAS = ["bag", "dress", "hat", "jacket", "pants", "shirt", "shoe", "shorts", "skirt", "sunglass"]
10
+
11
+
12
+ def process_image(image, marca, prenda):
13
+ """Visual Search Pipeline"""
14
+ vgg_search = extract_features_image(image)
15
+ database = select_database(marca, prenda)
16
+ result = search_similar_products(vgg_search, database)
17
+ return result
18
+
19
+
20
+ # Gradio app
21
+ examples = [
22
+ ["examples/bag_93.99.png", "Adidas", "bag"],
23
+ ["examples/shirt_82.84.png", "Nike", "shirt"],
24
+ ["examples/skirt_87.54.png", "Puma", "skirt"]
25
+ ]
26
+
27
+ title = "Visual Search 🔍 | Powered by Xpertium SA"
28
+ description = """
29
+ <p style='text-align: center'>Carga tu imagen y selecciona la marca & tipo de prenda.</p>
30
+ """
31
+
32
+ iface = gr.Interface(
33
+ fn=process_image,
34
+ inputs=[
35
+ gr.Image(label="imagen"),
36
+ gr.Dropdown(label="marca", choices=MARCAS, value=MARCAS[1]),
37
+ gr.Dropdown(label="prenda", choices=PRENDAS, value=PRENDAS[1]),
38
+ ],
39
+ outputs=gr.JSON(label="resultado"),
40
+ title=title,
41
+ examples=examples,
42
+ description=description
43
+ )
44
+
45
+ iface.launch()