Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
-
import
|
2 |
-
import
|
3 |
import google.generativeai as genai
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
token = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko"
|
6 |
-
genai.configure(
|
7 |
-
|
8 |
-
)
|
9 |
# Chargez l'image
|
10 |
model = genai.GenerativeModel(model_name="gemini-pro-vision")
|
|
|
11 |
# Fonction pour générer le contenu
|
12 |
def generate_content(image):
|
13 |
response = model.generate_content(["Write a short, engaging blog post based on this picture. It should include a description of the meal in the photo and talk about my journey meal prepping.", image], stream=True)
|
14 |
|
15 |
-
|
|
|
16 |
|
17 |
# Interface Gradio
|
18 |
iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs="text")
|
|
|
1 |
+
import pathlib
|
2 |
+
import textwrap
|
3 |
import google.generativeai as genai
|
4 |
+
from IPython.display import display, Markdown
|
5 |
+
|
6 |
+
def to_markdown(text):
|
7 |
+
text = text.replace('•', ' *')
|
8 |
+
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
|
9 |
|
10 |
token = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko"
|
11 |
+
genai.configure(api_key=token)
|
12 |
+
|
|
|
13 |
# Chargez l'image
|
14 |
model = genai.GenerativeModel(model_name="gemini-pro-vision")
|
15 |
+
|
16 |
# Fonction pour générer le contenu
|
17 |
def generate_content(image):
|
18 |
response = model.generate_content(["Write a short, engaging blog post based on this picture. It should include a description of the meal in the photo and talk about my journey meal prepping.", image], stream=True)
|
19 |
|
20 |
+
markdown_response = to_markdown(response.resolve())
|
21 |
+
return markdown_response
|
22 |
|
23 |
# Interface Gradio
|
24 |
iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs="text")
|