alexandrecorreia commited on
Commit
85a9cee
·
1 Parent(s): eb73e34

Solve images paths

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -42,14 +42,31 @@ theme = gr.themes.Base(
42
  font_mono=font_mono
43
  )
44
 
 
 
 
 
 
 
45
  def load_image(image_input):
46
- image_input.save("../../../Documents/images/img_path.jpg")
47
- os.system('docker cp "../../../Documents/images/img_path.jpg" marqo:"/images/images/"')
 
 
 
 
 
 
 
 
 
48
 
 
49
 
 
50
  def search_images(query, best_seller_score_weight):
51
- client = Client()
52
- result = client.index("multimodal").search(query, score_modifiers = {
53
  "add_to_score": [{"field_name": "best_seller_score","weight": best_seller_score_weight/1000}],
54
  }, searchable_attributes=['primary_image'], device="cpu", limit=5)
55
  imgs = [r for r in result["hits"]]
@@ -114,8 +131,8 @@ with gr.Blocks(theme=theme, title="New Look", css=css) as demo:
114
  gr.Examples(["Green", "Red", "Blue", "Sleeveless", "V-Neck", "Long dress, sleeveless, red"], text_input)
115
  gr.Markdown()
116
  gr.Examples(
117
- ["../../../Documents/images/2272.jpg",
118
- "../../../Documents/images/2697.jpg"],
119
  image_input)
120
  gr.Markdown()
121
  # with gr.Row().style(equal_height=False):
@@ -165,8 +182,8 @@ with gr.Blocks(theme=theme, title="New Look", css=css) as demo:
165
  bar_plot = gr.Plot()
166
  with gr.Row():
167
  gr.Examples(
168
- ["../../../Documents/images/2272.jpg",
169
- "../../../Documents/images/2697.jpg"],
170
  image_labels_input)
171
  gr.Markdown()
172
  compute_button = gr.Button(value="Compute")
 
42
  font_mono=font_mono
43
  )
44
 
45
+ ### Load local
46
+ # def load_image(image_input):
47
+ # image_input.save("../../../Documents/images/img_path.jpg")
48
+ # os.system('docker cp "../../../Documents/images/img_path.jpg" marqo:"/images/images/"')
49
+
50
+ ### Load AWS
51
  def load_image(image_input):
52
+ image_input.save("img_path.jpg")
53
+ os.system('docker cp "img_path.jpg" marqo:"/images/images/"')
54
+
55
+
56
+ ### Search local
57
+ # def search_images(query, best_seller_score_weight):
58
+ # client = Client()
59
+ # result = client.index("multimodal").search(query, score_modifiers = {
60
+ # "add_to_score": [{"field_name": "best_seller_score","weight": best_seller_score_weight/1000}],
61
+ # }, searchable_attributes=['primary_image'], device="cpu", limit=5)
62
+ # imgs = [r for r in result["hits"]]
63
 
64
+ # return imgs
65
 
66
+ ### Search AWS
67
  def search_images(query, best_seller_score_weight):
68
+ client = Client("http://ec2-54-220-125-165.eu-west-1.compute.amazonaws.com:8882")
69
+ result = client.index("test").search(query, score_modifiers = {
70
  "add_to_score": [{"field_name": "best_seller_score","weight": best_seller_score_weight/1000}],
71
  }, searchable_attributes=['primary_image'], device="cpu", limit=5)
72
  imgs = [r for r in result["hits"]]
 
131
  gr.Examples(["Green", "Red", "Blue", "Sleeveless", "V-Neck", "Long dress, sleeveless, red"], text_input)
132
  gr.Markdown()
133
  gr.Examples(
134
+ ["https://media2.newlookassets.com/i/newlook/869030934/womens/clothing/dresses/khaki-utility-mini-shirt-dress.jpg?strip=true&qlt=50&w=1400",
135
+ "https://media3.newlookassets.com/i/newlook/872692409/womens/clothing/dresses/black-floral-lace-trim-mini-dress.jpg?strip=true&qlt=50&w=1400"],
136
  image_input)
137
  gr.Markdown()
138
  # with gr.Row().style(equal_height=False):
 
182
  bar_plot = gr.Plot()
183
  with gr.Row():
184
  gr.Examples(
185
+ ["https://media2.newlookassets.com/i/newlook/869030934/womens/clothing/dresses/khaki-utility-mini-shirt-dress.jpg?strip=true&qlt=50&w=1400",
186
+ "https://media3.newlookassets.com/i/newlook/872692409/womens/clothing/dresses/black-floral-lace-trim-mini-dress.jpg?strip=true&qlt=50&w=1400"],
187
  image_labels_input)
188
  gr.Markdown()
189
  compute_button = gr.Button(value="Compute")