lodhrangpt commited on
Commit
c389c88
·
verified ·
1 Parent(s): 7e704c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -14
app.py CHANGED
@@ -88,22 +88,34 @@ def process_food_result(image, language,progress= gr.Progress()):
88
 
89
  # Generate output in the selected language
90
 
91
-
92
- # For English output
93
  output_en = f"""
94
- <div style='text-align: left;'>
95
- <b>Food</b>: {food_item}<br>
96
- <b>Serving Size</b>: {serving_size_text_en}<br>
97
- <b>Calories</b>: {calories} kcal<br>
98
- <b>Protein</b>: {protein}g<br>
99
- <b>Carbohydrates</b>: {carbs}g<br>
100
- <b>Sugars</b>: {sugars}g<br>
101
- <b>Fiber</b>: {fiber}g<br>
102
- <b>Sodium</b>: {sodium}mg<br>
103
- <b>Fat</b>: {fat}g
104
- </div>
105
  """
106
  return output_en
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  # Gradio interface function
109
  def gradio_function(image, language):
@@ -116,7 +128,7 @@ def gradio_function(image, language):
116
  iface = gr.Interface(
117
  fn=gradio_function, # Function to call
118
  inputs=[gr.Image(type="pil", label="Upload an image")], # Input: Dropdown for language selection
119
- outputs=gr.HTML(label="Food and Nutrition Information"), # Output: HTML for displaying nutrition info
120
  title="Bilingual Food Recognition and Nutrition Info Tool", # Title of the Gradio interface
121
  description="Upload an image of food, and the tool will recognize it and provide nutritional information in both English or Arabic languages." # Description of the tool
122
  )
 
88
 
89
  # Generate output in the selected language
90
 
91
+
 
92
  output_en = f"""
93
+ Food: {food_item}
94
+ Serving Size: {serving_size_text_en}
95
+ Calories: {calories} kcal
96
+ Protein: {protein}g
97
+ Carbohydrates: {carbs}g
98
+ Sugars: {sugars}g
99
+ Fiber: {fiber}g
100
+ Sodium: {sodium}mg
101
+ Fat: {fat}g
 
 
102
  """
103
  return output_en
104
+ # # For English output
105
+ # output_en = f"""
106
+ # <div style='text-align: left;'>
107
+ # <b>Food</b>: {food_item}<br>
108
+ # <b>Serving Size</b>: {serving_size_text_en}<br>
109
+ # <b>Calories</b>: {calories} kcal<br>
110
+ # <b>Protein</b>: {protein}g<br>
111
+ # <b>Carbohydrates</b>: {carbs}g<br>
112
+ # <b>Sugars</b>: {sugars}g<br>
113
+ # <b>Fiber</b>: {fiber}g<br>
114
+ # <b>Sodium</b>: {sodium}mg<br>
115
+ # <b>Fat</b>: {fat}g
116
+ # </div>
117
+ # """
118
+ # return output_en
119
 
120
  # Gradio interface function
121
  def gradio_function(image, language):
 
128
  iface = gr.Interface(
129
  fn=gradio_function, # Function to call
130
  inputs=[gr.Image(type="pil", label="Upload an image")], # Input: Dropdown for language selection
131
+ outputs=gr.textbox(label="Food and Nutrition Information"), # Output: HTML for displaying nutrition info
132
  title="Bilingual Food Recognition and Nutrition Info Tool", # Title of the Gradio interface
133
  description="Upload an image of food, and the tool will recognize it and provide nutritional information in both English or Arabic languages." # Description of the tool
134
  )