|
import google.generativeai as genai |
|
from PIL import Image |
|
import streamlit as st |
|
import io |
|
|
|
|
|
GOOGLE_API_KEY = "AIzaSyAesEWBYNPVIw5dde2LiZDXWDDJ8by90XI" |
|
genai.configure(api_key=GOOGLE_API_KEY) |
|
model = genai.GenerativeModel("gemini-1.5-pro") |
|
|
|
|
|
def extract_text(image): |
|
|
|
if image.mode != 'RGB': |
|
image = image.convert('RGB') |
|
|
|
|
|
response = model.generate_content( |
|
["successfully extracts hindi and english text from the image and returns the extracted text in a structured format (plain text)", image] |
|
) |
|
|
|
return response.text |
|
|
|
|
|
|
|
|