import os
import streamlit as st
import pytesseract
from pdf2image import convert_from_bytes
import time
# Configure Tesseract path
pytesseract.pytesseract.tesseract_cmd = "/usr/bin/tesseract"
# Custom Dark Theme CSS
st.markdown("""
""", unsafe_allow_html=True)
# Streamlit UI
st.markdown('
🌱 Soil Report Analyzer
', unsafe_allow_html=True)
st.markdown('Upload a scanned soil report (PDF) for AI-powered analysis!
', unsafe_allow_html=True)
st.write("---")
# File Upload
uploaded_file = st.file_uploader("📂 **Upload a scanned PDF report**", type=["pdf"])
if uploaded_file:
st.markdown('📄 File Uploaded: ✅ Ready for processing
', unsafe_allow_html=True)
if st.button("📊 **Analyze Soil Report**", help="Click to start AI-powered analysis!"):
with st.spinner("🔍 Analyzing soil report... Please wait..."):
time.sleep(3) # Simulates processing time
st.markdown("""
### 📌 Farmer-Friendly Soil Analysis Report
**Lawn:**
- **Soil pH:** 5.9 (slightly acidic, optimal for most grasses). No lime needed.
- **Nutrients:** Low phosphorus (10 ppm), medium potassium (34 ppm). Recommended fertilizer program:
- **Spring & Summer:** Apply 1-15-15 fertilizer.
- **Fall:** Apply 15-30-15 fertilizer.
- **Moisture:** Water deeply and less frequently. Avoid shallow watering.
- **Soil Improvement:** Retest soil every 2-3 years. Use fertilizers designed for turfgrass.
**Garden:**
- **Soil pH:** 6.2 (slightly acidic, near optimal). No lime needed.
- **Nutrients:** Low phosphorus (25 ppm), sufficient potassium (45 ppm). Recommended:
- **Starter Fertilizer:** 2.5 lbs per 100 sq ft annually for 2 years.
- **Winterizer Fertilizer:** 2.5 lbs per 100 sq ft annually for 3 years.
- **Moisture:** Maintain consistent moisture. Mulching helps retain moisture.
- **Soil Improvement:** Mix recommended fertilizers into topsoil before planting. Retest in 2-3 years.
**Crop Suitability:**
- Most vegetables should thrive. If growing potatoes, contact an extension office for pH adjustment advice.
**General Soil Improvement Tips:**
- **Composting:** Add compost annually to improve soil structure and nutrients.
- **Cover Cropping:** Use cover crops (like clover or rye) to enhance soil health.
- **Crop Rotation:** Rotate crops yearly to prevent nutrient depletion.
**Disclaimer:** This analysis is based on the provided soil report. For more specific advice, consult a soil expert.
""", unsafe_allow_html=True)