Spaces:
Sleeping
Sleeping
import gradio as gr | |
import google.generativeai as genai | |
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(pro,image): | |
response = model.generate_content([pro, image]) | |
print(response.text) | |
c = response.text # Utilisez la variable c au lieu de e | |
return c | |
# Fonction pour afficher le contenu en markdown | |
def display_markdown(c): # Utilisez le paramètre c | |
markdown = f""" | |
{c} | |
"""# Utilisez la variable c | |
with gr.Blocks() as demo: | |
gr.Markdown(markdown, latex_delimiters=[{ "left": "$$", "right": "$$", "display": True }]) | |
return demo | |
# Interface Gradio | |
iface = gr.Interface(fn=[generate_content, display_markdown], inputs=[gr.Textbox(),gr.Image(type='pil')], outputs=["text", "html"]) | |
iface.launch(share=True) | |