Spaces:
Sleeping
Sleeping
import gradio as gr | |
import google.generativeai as genai | |
import os | |
token=os.environ.get("TOKEN") | |
e = "" | |
genai.configure( | |
api_key=token | |
) | |
generation_config = { | |
"temperature": 1, | |
"top_p": 0.95, | |
"top_k": 64, | |
"max_output_tokens": 8192, | |
} | |
safety_settings = [ | |
{ | |
"category": "HARM_CATEGORY_HARASSMENT", | |
"threshold": "BLOCK_NONE" | |
}, | |
{ | |
"category": "HARM_CATEGORY_HATE_SPEECH", | |
"threshold": "BLOCK_NONE" | |
}, | |
{ | |
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", | |
"threshold": "BLOCK_NONE" | |
}, | |
{ | |
"category": "HARM_CATEGORY_DANGEROUS_CONTENT", | |
"threshold": "BLOCK_NONE" | |
}, | |
] | |
mm = """ resous cet exercice. réponse attendue uniquement en Latex | |
""" | |
model = genai.GenerativeModel(model_name="gemini-1.5-pro", | |
generation_config=generation_config,system_instruction=mm , | |
safety_settings=safety_settings) | |
# Fonction pour générer le contenu | |
def generate_content(image): | |
global e | |
if not image: | |
e =" djo" | |
else: | |
response = model.generate_content([image]) | |
print(response.text) | |
e= response.text | |
return e | |
iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs= gr.Textbox()) | |
iface.launch() |