Spaces:
Sleeping
Sleeping
File size: 910 Bytes
6f1f950 4b51045 6f1f950 24488cc 4b51045 6f1f950 24488cc 4b51045 6f1f950 24488cc 94e6376 6f1f950 24488cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import pathlib
import textwrap
import google.generativeai as genai
from IPython.display import display, Markdown
def to_markdown(text):
text = text.replace('•', ' *')
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
token = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko"
genai.configure(api_key=token)
# Chargez l'image
model = genai.GenerativeModel(model_name="gemini-pro-vision")
# Fonction pour générer le contenu
def generate_content(image):
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)
markdown_response = to_markdown(response.resolve())
return markdown_response
# Interface Gradio
iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs="text")
iface.launch()
|