Spaces:
Runtime error
Runtime error
File size: 3,280 Bytes
a147a85 af0eb41 a147a85 af0eb41 a2bbded af0eb41 1d32868 990f906 af0eb41 a2bbded af0eb41 dc896b6 d294c03 64718b0 dc896b6 64718b0 af0eb41 64718b0 dc896b6 af0eb41 54ce4f3 af0eb41 dc896b6 af0eb41 dc896b6 af0eb41 dc896b6 af0eb41 dc896b6 af0eb41 dc896b6 af0eb41 6cac93a af0eb41 dc896b6 af0eb41 dc896b6 6cac93a 54ce4f3 a147a85 af0eb41 |
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import gradio as gr
import pandas as pd
def get_crop_recommendation(soil_type, climate, history):
# Replace with your actual model inference logic
recommendations = {
"soil": soil_type,
"climate": climate,
"recommended_crops": ["Pepper", "Tomato", "Chilli"],
"confidence": [0.85, 0.76, 0.68]
}
return pd.DataFrame(recommendations)
def analyze_conditions(query, history):
# Condition analysis handler (connect to your LLM)
response = f"π± CropAI Analysis: Optimal cultivation patterns suggest {get_crop_recommendation('Loam', 'Tropical', '').iloc[0]['recommended_crops'][0]} for these conditions."
return response
with gr.Blocks(theme=gr.themes.Soft(), title="CropSeek-LLM") as demo:
gr.HTML("""
<div style="text-align:center"; background: linear-gradient(to right, #2c5f2d, #97bc62); padding: 20px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<img src="https://huggingface.co/spaces/DARJYO/CropSeek-LLM/resolve/main/assets/logo.png"
style="height:80px; margin-bottom:20px;">
</div>
""")
gr.Markdown("### πΎ Agricultural Intelligence System")
with gr.Tab("π± Field Analysis Console"):
with gr.Row():
with gr.Column(scale=2):
analysis_log = gr.Chatbot(
label="Crop Diagnosis History",
avatar_images=("π§πΎ", "π€"),
height=400
)
with gr.Column(scale=1):
field_input = gr.Textbox(
label="Describe Soil & Climate Conditions:",
placeholder="e.g. 'Clay soil in tropical climate with moderate rainfall...'"
)
analyze_btn = gr.Button("π¦οΈ Analyze Agricultural Patterns", variant="primary")
analyze_btn.click(
analyze_conditions,
[field_input, analysis_log],
[field_input, analysis_log]
)
with gr.Tab("π Yield Optimization Advisor"):
with gr.Row():
soil_dd = gr.Dropdown(
["Loamy", "Clay", "Sandy"],
label="Soil Composition",
info="Select predominant soil type"
)
climate_dd = gr.Dropdown(
["Tropical", "Temperate", "Arid"],
label="Climate Profile",
info="Select regional climate pattern"
)
farm_data = gr.File(
label="Upload Field Sensor Data (CSV)",
file_types=[".csv"]
)
simulate_btn = gr.Button("π Generate Cultivation Plan", variant="primary")
results = gr.Dataframe(
headers=["Parameter", "Value", "Recommendation"],
interactive=False,
wrap=True,
datatype=["str", "number", "str"]
)
simulate_btn.click(
fn=get_crop_recommendation,
inputs=[soil_dd, climate_dd, farm_data],
outputs=results
)
gr.Markdown("""
<div style="text-align: center; padding: 15px; background-color: #f8f9fa; border-radius: 8px; margin-top: 20px;">
<small>Β© 2025 DARJYO/CropSeek-LLM</small>
</div>
""")
demo.launch() |