valentynliubchenko commited on
Commit
4a10a29
·
1 Parent(s): 47e8809

added examples

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. algorithm/product.py +2 -3
  2. algorithm/receipt.py +0 -8
  3. algorithm/receipt_calculation.py +6 -6
  4. app.py +19 -2
  5. convert_to_webp.py +30 -0
  6. examples/{farmacy_1.jpg → 5404832557079585491.webp} +2 -2
  7. examples/ATB_11.jpg +0 -3
  8. examples/{cafe.png → ATB_11.webp} +2 -2
  9. examples/{5404832557079585491.jpg → Sportisimo.webp} +2 -2
  10. examples/{farmacy_2.jpg → cafe.webp} +2 -2
  11. examples/{Sportisimo.jpg → farmacy_1.webp} +2 -2
  12. examples/farmacy_2.webp +3 -0
  13. examples/fatlouis.webp +3 -0
  14. examples/garm_3.JPG +0 -3
  15. examples/garm_3.webp +3 -0
  16. examples/image_2024_09_25T12_13_01_811Z.png +0 -3
  17. examples/image_2024_09_25T12_13_01_811Z.webp +3 -0
  18. examples/lidl1.jpg +0 -3
  19. examples/lidl1.webp +3 -0
  20. examples/lidl2.jpg +0 -3
  21. examples/lidl2.webp +3 -0
  22. examples/photo_2024-09-10_10-06-14.jpg +0 -3
  23. examples/photo_2024-09-10_10-06-14.webp +3 -0
  24. examples/photo_2024-09-10_10-06-24.jpg +0 -3
  25. examples/photo_2024-09-10_10-06-24.webp +3 -0
  26. examples/photo_2024-09-10_10-06-28.jpg +0 -3
  27. examples/photo_2024-09-10_10-06-28.webp +3 -0
  28. examples/photo_2024-09-24_14-50-34.jpg +0 -3
  29. examples/photo_2024-09-24_14-50-34.webp +3 -0
  30. examples/tiket.jpg +0 -3
  31. examples/tiket.webp +3 -0
  32. examples_canada/photo_2024-10-09_14-21-54.webp +0 -0
  33. examples_canada/photo_2024-10-09_14-23-03.webp +0 -0
  34. examples_france/photo_1_2024-10-02_00-08-53.webp +0 -0
  35. examples_france/photo_2024-10-07_21-46-05.webp +0 -0
  36. examples_france/photo_2024-10-07_21-46-27.webp +0 -0
  37. examples_france/photo_2_2024-10-02_00-08-53.webp +0 -0
  38. examples_france/photo_3_2024-10-02_00-08-53.webp +0 -0
  39. examples_france/photo_4_2024-10-02_00-08-53.webp +0 -0
  40. examples_france/photo_5_2024-10-02_00-08-53.webp +0 -0
  41. examples_france/photo_6_2024-10-02_00-08-53.webp +0 -0
  42. examples_france/photo_7_2024-10-02_00-08-53.webp +0 -0
  43. examples_france/photo_8_2024-10-02_00-08-53.webp +0 -0
  44. examples_us/Photo Sep 29 2024, 15 43 17.webp +0 -0
  45. examples_us/Photo Sep 29 2024, 15 43 30.webp +0 -0
  46. examples_us/Photo Sep 29 2024, 15 43 48.webp +0 -0
  47. examples_us/Photo Sep 29 2024, 15 44 21.webp +0 -0
  48. examples_us/Photo Sep 29 2024, 15 44 42.webp +0 -0
  49. examples_us/Photo Sep 29 2024, 15 45 13.webp +0 -0
  50. examples_us/Photo Sep 29 2024, 15 45 26.webp +0 -0
algorithm/product.py CHANGED
@@ -1,8 +1,7 @@
1
  class Product:
2
- def __init__(self, name, price, quantity):
3
  self.name = name
4
  self.price = price
5
- self.quantity = quantity
6
 
7
  def __repr__(self):
8
- return f"Product(name={self.name}, price={self.price}, quantity={self.quantity})"
 
1
  class Product:
2
+ def __init__(self, name, price):
3
  self.name = name
4
  self.price = price
 
5
 
6
  def __repr__(self):
7
+ return f"Product(name={self.name}, price={self.price})"
algorithm/receipt.py DELETED
@@ -1,8 +0,0 @@
1
- class Receipt:
2
- def __init__(self, products, tax, total_amount):
3
- self.products = products
4
- self.tax = tax
5
- self.total_amount = total_amount
6
-
7
- def __repr__(self):
8
- return f"Receipt(products={self.products}, tax={self.tax}, total_amount={self.total_amount})"
 
 
 
 
 
 
 
 
 
algorithm/receipt_calculation.py CHANGED
@@ -93,21 +93,21 @@ def calculate_tips_and_taxes(items_table, total_amount, tax, tips):
93
  if items_table[0][0] == "No items":
94
  return products, 0
95
 
96
- if total_amount == "Not specified" or total_amount is None:
97
  total_amount = "0.0"
98
 
99
- if tax == "Not specified" or tax is None:
100
  tax = "0.0"
101
 
102
- if tips == "Not specified" or tips is None:
103
- tax = "0.0"
104
 
105
  for item in items_table:
106
  price = item[5]
107
- if price == "Not specified":
108
  price = "0.0"
109
  item_value = float(str(price).replace(",", ".")) if item[5] is not None else 0.0
110
- products.append(Product(item[0], item_value, item[3]))
111
 
112
  sum_of_product_prices = 0
113
  for _product in products:
 
93
  if items_table[0][0] == "No items":
94
  return products, 0
95
 
96
+ if total_amount == "Not specified" or total_amount == "unknown" or total_amount is None:
97
  total_amount = "0.0"
98
 
99
+ if tax == "Not specified" or tax == "unknown" or tax is None:
100
  tax = "0.0"
101
 
102
+ if tips == "Not specified" or tips == "unknown" or tips is None:
103
+ tips = "0.0"
104
 
105
  for item in items_table:
106
  price = item[5]
107
+ if price == "Not specified" or price == "unknown":
108
  price = "0.0"
109
  item_value = float(str(price).replace(",", ".")) if item[5] is not None else 0.0
110
+ products.append(Product(item[0], item_value))
111
 
112
  sum_of_product_prices = 0
113
  for _product in products:
app.py CHANGED
@@ -14,6 +14,10 @@ from vertex_ai_service import VertexAIService
14
  model_names = ["gemini-1.5-flash", "gemini-1.5-pro", "gpt-4o-mini", "gpt-4o", "gpt-4-turbo"]
15
  prompt_names = ["prompt_v1", "prompt_v2", "prompt_v3"]
16
  example_list = [["./examples/" + example] for example in os.listdir("examples")]
 
 
 
 
17
  prompt_default = read_prompt_from_file("prompt_v1.txt")
18
  system_instruction = read_prompt_from_file("system_instruction.txt")
19
 
@@ -258,6 +262,19 @@ with gr.Blocks() as iface:
258
  )
259
  prompt_radio.change(fn=update_prompt_from_radio, inputs=[prompt_radio], outputs=[custom_prompt])
260
  gr.Examples(examples=example_list,
261
- inputs=[image_input, model_radio, prompt_radio, temperature_slider, custom_prompt])
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
- iface.launch(share=True)
 
14
  model_names = ["gemini-1.5-flash", "gemini-1.5-pro", "gpt-4o-mini", "gpt-4o", "gpt-4-turbo"]
15
  prompt_names = ["prompt_v1", "prompt_v2", "prompt_v3"]
16
  example_list = [["./examples/" + example] for example in os.listdir("examples")]
17
+ example_list_us = [["./examples_us/" + example] for example in os.listdir("examples_us")]
18
+ example_list_canada = [["./examples_canada/" + example] for example in os.listdir("examples_canada")]
19
+ example_france = [["./examples_france/" + example] for example in os.listdir("examples_france")]
20
+
21
  prompt_default = read_prompt_from_file("prompt_v1.txt")
22
  system_instruction = read_prompt_from_file("system_instruction.txt")
23
 
 
262
  )
263
  prompt_radio.change(fn=update_prompt_from_radio, inputs=[prompt_radio], outputs=[custom_prompt])
264
  gr.Examples(examples=example_list,
265
+ inputs=[image_input, model_radio, prompt_radio, temperature_slider, custom_prompt],
266
+ label="Examples for general use")
267
+
268
+ gr.Examples(examples=example_list_us,
269
+ inputs=[image_input, model_radio, prompt_radio, temperature_slider, custom_prompt],
270
+ label="Examples for US")
271
+
272
+ gr.Examples(examples=example_list_canada,
273
+ inputs=[image_input, model_radio, prompt_radio, temperature_slider, custom_prompt],
274
+ label="Examples for Canada")
275
+
276
+ gr.Examples(examples=example_france,
277
+ inputs=[image_input, model_radio, prompt_radio, temperature_slider, custom_prompt],
278
+ label="Examples for France")
279
 
280
+ iface.launch()
convert_to_webp.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+ import os
3
+
4
+
5
+ def convert_to_webp(input_file, output_file=None):
6
+ try:
7
+ img = Image.open(input_file)
8
+ if output_file is None:
9
+ base_name = os.path.splitext(input_file)[0]
10
+ output_file = f"{base_name}.webp"
11
+
12
+ img.save(output_file, "WEBP")
13
+ print(f"saved as {output_file}")
14
+
15
+ except Exception as e:
16
+ print(f"error saving: {e}")
17
+
18
+
19
+ def process_images_in_directory(directory):
20
+ print(directory)
21
+ for filename in os.listdir(directory):
22
+ if filename.lower().endswith(('.jpg', '.png', '.jpeg')):
23
+ input_path = os.path.join(directory, filename)
24
+ convert_to_webp(input_path)
25
+
26
+ if __name__ == "__main__":
27
+ current_directory = os.getcwd()
28
+ print(f"current_directory: {current_directory}")
29
+ directory = "./examples_france/"
30
+ process_images_in_directory(directory)
examples/{farmacy_1.jpg → 5404832557079585491.webp} RENAMED
File without changes
examples/ATB_11.jpg DELETED

Git LFS Details

  • SHA256: 12fa36ea87d6f691b32d9f8c97a7c918a9a241fbb1e0c9bff875891b60f21789
  • Pointer size: 132 Bytes
  • Size of remote file: 4.73 MB
examples/{cafe.png → ATB_11.webp} RENAMED
File without changes
examples/{5404832557079585491.jpg → Sportisimo.webp} RENAMED
File without changes
examples/{farmacy_2.jpg → cafe.webp} RENAMED
File without changes
examples/{Sportisimo.jpg → farmacy_1.webp} RENAMED
File without changes
examples/farmacy_2.webp ADDED

Git LFS Details

  • SHA256: 378a4852aff0af61fe18d9282d9dadd95eea6f1672faf0534d16ac33762844ed
  • Pointer size: 130 Bytes
  • Size of remote file: 99 kB
examples/fatlouis.webp ADDED

Git LFS Details

  • SHA256: 07caf0b01f2c13e15e97f8358a325a3cdcaf18f34b685529d67217e6a0c0f893
  • Pointer size: 131 Bytes
  • Size of remote file: 153 kB
examples/garm_3.JPG DELETED

Git LFS Details

  • SHA256: c1444d4b5ae75ae1c2e70ab3de67d6505ef11c45e7f1be3faf1902e6474014d3
  • Pointer size: 132 Bytes
  • Size of remote file: 2.18 MB
examples/garm_3.webp ADDED

Git LFS Details

  • SHA256: 419abb20db12bd8885826d52ddb1fb9d0a0b897c9125e35eb11ed8b177d9157d
  • Pointer size: 131 Bytes
  • Size of remote file: 608 kB
examples/image_2024_09_25T12_13_01_811Z.png DELETED

Git LFS Details

  • SHA256: e84d0fee6867825b325df2da52efb949406ef1d821923fd99fcad38c4dad92a8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.36 MB
examples/image_2024_09_25T12_13_01_811Z.webp ADDED

Git LFS Details

  • SHA256: 2c14d7d8549fedc90b2179df6ada2c27dd235c15754ab646ca2a1273e5906195
  • Pointer size: 130 Bytes
  • Size of remote file: 89.1 kB
examples/lidl1.jpg DELETED

Git LFS Details

  • SHA256: e13896a25ffee139c52a1be9cd0cf0525af45c56fb7aa21ca375206d3f2bc495
  • Pointer size: 131 Bytes
  • Size of remote file: 100 kB
examples/lidl1.webp ADDED

Git LFS Details

  • SHA256: f68d048dbf532c28e67f9ca18476109feb2733f586138234683a9045cad0e543
  • Pointer size: 130 Bytes
  • Size of remote file: 52.3 kB
examples/lidl2.jpg DELETED

Git LFS Details

  • SHA256: 9e0a8f8398bf9eca3d4fa5ba8f3b0b00cbd5b1f8278a24b77166302f3cb56453
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
examples/lidl2.webp ADDED

Git LFS Details

  • SHA256: c3a70b5517303c3d0d703cc46afcdeac64d191ba9f393b543665feabad70b55f
  • Pointer size: 130 Bytes
  • Size of remote file: 69.7 kB
examples/photo_2024-09-10_10-06-14.jpg DELETED

Git LFS Details

  • SHA256: 3e6fc8e73ccbda7eb5c38ab55a9750624a4380a2716babb2e4ae7844ea30108c
  • Pointer size: 131 Bytes
  • Size of remote file: 159 kB
examples/photo_2024-09-10_10-06-14.webp ADDED

Git LFS Details

  • SHA256: e8692e1ad094ce9efcd45e74ddcf8f4867c6809b653f95abc86775efebfff22d
  • Pointer size: 130 Bytes
  • Size of remote file: 85.4 kB
examples/photo_2024-09-10_10-06-24.jpg DELETED

Git LFS Details

  • SHA256: 4fe19064b828a47ef99ee9001f79e3fa8b597fd5f06d9c4bb098761a025fe1d6
  • Pointer size: 131 Bytes
  • Size of remote file: 124 kB
examples/photo_2024-09-10_10-06-24.webp ADDED

Git LFS Details

  • SHA256: abd73a7185d3bf079071bada32756dd6bc58db4f8704d36452731b4c6fc17bf0
  • Pointer size: 130 Bytes
  • Size of remote file: 59.8 kB
examples/photo_2024-09-10_10-06-28.jpg DELETED

Git LFS Details

  • SHA256: 078ec637f509a90c4f1a8b374eba218f093f3bfbba9314e12bec4a23a9217a38
  • Pointer size: 131 Bytes
  • Size of remote file: 140 kB
examples/photo_2024-09-10_10-06-28.webp ADDED

Git LFS Details

  • SHA256: 6f4c1bd4f2e2b11827c645349f9b74babd240b3226b3355c847f01de76d7034d
  • Pointer size: 130 Bytes
  • Size of remote file: 83.3 kB
examples/photo_2024-09-24_14-50-34.jpg DELETED

Git LFS Details

  • SHA256: 26f24a52d85b95b09c0770c9107f42878fb1298a6331c7cdd27ac8128625509c
  • Pointer size: 131 Bytes
  • Size of remote file: 245 kB
examples/photo_2024-09-24_14-50-34.webp ADDED

Git LFS Details

  • SHA256: e4c982df0ac83dde7a6641ab25b47edf3fbedcf188f3125053bdb9172b35b25f
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
examples/tiket.jpg DELETED

Git LFS Details

  • SHA256: aba99a5a1c193f00feb02048f590697629f91af5d64caeeab58303c5fa4807b6
  • Pointer size: 131 Bytes
  • Size of remote file: 141 kB
examples/tiket.webp ADDED

Git LFS Details

  • SHA256: 386ed5c34b497ba0b693492c0051e63e4757337770800995be42807645239ce4
  • Pointer size: 131 Bytes
  • Size of remote file: 113 kB
examples_canada/photo_2024-10-09_14-21-54.webp ADDED
examples_canada/photo_2024-10-09_14-23-03.webp ADDED
examples_france/photo_1_2024-10-02_00-08-53.webp ADDED
examples_france/photo_2024-10-07_21-46-05.webp ADDED
examples_france/photo_2024-10-07_21-46-27.webp ADDED
examples_france/photo_2_2024-10-02_00-08-53.webp ADDED
examples_france/photo_3_2024-10-02_00-08-53.webp ADDED
examples_france/photo_4_2024-10-02_00-08-53.webp ADDED
examples_france/photo_5_2024-10-02_00-08-53.webp ADDED
examples_france/photo_6_2024-10-02_00-08-53.webp ADDED
examples_france/photo_7_2024-10-02_00-08-53.webp ADDED
examples_france/photo_8_2024-10-02_00-08-53.webp ADDED
examples_us/Photo Sep 29 2024, 15 43 17.webp ADDED
examples_us/Photo Sep 29 2024, 15 43 30.webp ADDED
examples_us/Photo Sep 29 2024, 15 43 48.webp ADDED
examples_us/Photo Sep 29 2024, 15 44 21.webp ADDED
examples_us/Photo Sep 29 2024, 15 44 42.webp ADDED
examples_us/Photo Sep 29 2024, 15 45 13.webp ADDED
examples_us/Photo Sep 29 2024, 15 45 26.webp ADDED