Spaces:
Runtime error
Runtime error
File size: 1,679 Bytes
f347e77 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import google.generativeai as genai
import gradio as gr
import os
generation_config = {
"temperature": 0,
"top_p": 1,
"top_k": 32,
"max_output_token": 4096,
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
]
genai.configure(api_key="AIzaSyAEinSmbNfJHdThXN2nA3Oxf82Qb7zQsLo")
model = genai.GenerativeModel(model_name="gemini-pro-vision",
generation_config=generation_config,
safety_settings=safety_settings)
import_prompt = """ """
def upload_file(files, text_input):
file_paths = [file.name for file in files]
if file_paths:
response = generate_gemini_response(input_prompt, text_input, file_paths[0])
return file_paths[0], response
with gr.Blocks() as demo:
header = gr.Label("Please let us know about your injury and Gen AI will try to help you")
text_input = gr.Textbox(label="Explain a bit more about your injury")
image_output = gr.Image()
upload_button = gr.UploadButton("Upload an image",
file_type=["image"],
file_count="multiple")
file_output = gr.Textbox(label="First-aid process")
combined_output = [image_output, file_output]
upload_button.upload(upload_file, [upload_button, text_input], combined_output)
demo.launch(debug=True)
|