Abduuu commited on
Commit
37dad77
1 Parent(s): b1d6e1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import wget
4
  from transformers import pipeline
5
  import requests
 
6
 
7
  # Nutritionix API setup
8
  api_url = "https://trackapi.nutritionix.com/v2/natural/nutrients"
@@ -15,11 +16,14 @@ headers = {
15
 
16
  # Load the Models
17
 
 
 
 
18
  # Load the BLIP VQA Model (Recognize the food)
19
- visual_quest_ans = pipeline("visual-question-answering", model="Salesforce/blip-vqa-base")
20
 
21
  # Load the Translation Model (English to Arabic)
22
- translation_eng_to_ar = pipeline("translation_en_to_ar", model="marefa-nlp/marefa-mt-en-ar")
23
 
24
  # Function to recognize food from the image using the VQA model
25
  def food_recognizer(image):
 
3
  import wget
4
  from transformers import pipeline
5
  import requests
6
+ import torch
7
 
8
  # Nutritionix API setup
9
  api_url = "https://trackapi.nutritionix.com/v2/natural/nutrients"
 
16
 
17
  # Load the Models
18
 
19
+ # Check if a GPU is available
20
+ device = 0 if torch.cuda.is_available() else -1
21
+
22
  # Load the BLIP VQA Model (Recognize the food)
23
+ visual_quest_ans = pipeline("visual-question-answering", model="Salesforce/blip-vqa-base", device=device)
24
 
25
  # Load the Translation Model (English to Arabic)
26
+ translation_eng_to_ar = pipeline("translation_en_to_ar", model="marefa-nlp/marefa-mt-en-ar", device=device)
27
 
28
  # Function to recognize food from the image using the VQA model
29
  def food_recognizer(image):