import gradio as gr import google.generativeai as genai import numpy as np import base64 import pathlib import textwrap import os secret_key =os.getenv("API_KEY") genai.configure(api_key = secret_key) model = genai.GenerativeModel('gemini-pro-vision') def generate_prescription(image): response = model.generate_content(["Identify the vegetable/fruit and analyze its current shelf life, ripening period, and ideal market timing post-ripening. Detail the prime harvest season and offer both the present and expected market rates in INR within the Indian market after sale. Further, determine the optimal Indian state for selling this produce, providing both the state's name and its geographical coordinates for map plotting purposes.", image]) return response.text interface = gr.Interface(fn=generate_prescription, inputs=gr.Image(label="Upload image", sources=['upload', 'webcam'], type="pil"), outputs=gr.Textbox(label="Produce Details"), title="FarmScan", description="Add/Upload an image of your produce (vegetable or fruits) and learn about its shelf life, ripening period, market time, best time to harvest and best market to sell.", allow_flagging="never") if __name__ == "__main__": interface.launch()