Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
import google.generativeai as genai
|
3 |
from yolov5 import YOLOv5
|
4 |
from PIL import Image
|
5 |
-
|
6 |
|
7 |
#Clé Api
|
8 |
genai.configure(api_key="AIzaSyB_Hnl_77gd1I8xs6iuLqKIoGHgsZMXm1M")
|
@@ -15,6 +15,10 @@ gemini_model = genai.GenerativeModel('gemini-pro')
|
|
15 |
yolo_model_path = "yolov5s.pt"
|
16 |
yolo_model = YOLOv5(yolo_model_path, device="cpu")
|
17 |
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Détection d'ingrédients
|
20 |
def detect_ingredients(image):
|
@@ -50,8 +54,6 @@ def generate_recipe(ingredients):
|
|
50 |
response = gemini_model.generate_content(prompt)
|
51 |
return response.text
|
52 |
|
53 |
-
response = gemini_model.generatecontent(prompt)
|
54 |
-
return response.text
|
55 |
|
56 |
|
57 |
# Interface Gradio
|
@@ -61,6 +63,11 @@ def process_image(image):
|
|
61 |
recipe = generate_recipe(ingredients)
|
62 |
return f"Ingrédients détectés : {', '.join(ingredients)}\n\nRecette générée :\n{recipe}"
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
# Mise à jour de l'interface Gradio
|
66 |
iface = gr.Interface(
|
|
|
2 |
import google.generativeai as genai
|
3 |
from yolov5 import YOLOv5
|
4 |
from PIL import Image
|
5 |
+
from transformers import AutoProcessor, BarkModel
|
6 |
|
7 |
#Clé Api
|
8 |
genai.configure(api_key="AIzaSyB_Hnl_77gd1I8xs6iuLqKIoGHgsZMXm1M")
|
|
|
15 |
yolo_model_path = "yolov5s.pt"
|
16 |
yolo_model = YOLOv5(yolo_model_path, device="cpu")
|
17 |
|
18 |
+
# Modèle Bark
|
19 |
+
processor = AutoProcessor.from_pretrained("suno/bark")
|
20 |
+
model = BarkModel.from_pretrained("suno/bark")
|
21 |
+
|
22 |
|
23 |
# Détection d'ingrédients
|
24 |
def detect_ingredients(image):
|
|
|
54 |
response = gemini_model.generate_content(prompt)
|
55 |
return response.text
|
56 |
|
|
|
|
|
57 |
|
58 |
|
59 |
# Interface Gradio
|
|
|
63 |
recipe = generate_recipe(ingredients)
|
64 |
return f"Ingrédients détectés : {', '.join(ingredients)}\n\nRecette générée :\n{recipe}"
|
65 |
|
66 |
+
# Fonction pour générer de l'audio avec le modèle Bark
|
67 |
+
def generate_audio(text):
|
68 |
+
inputs = processor(text=text, return_tensors="pt")
|
69 |
+
audio_output = model.generate(**inputs)
|
70 |
+
return audio_output
|
71 |
|
72 |
# Mise à jour de l'interface Gradio
|
73 |
iface = gr.Interface(
|