Spaces:
Sleeping
Sleeping
| 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(""" | |
| <style> | |
| body { | |
| background-color: #121212; | |
| color: #E0E0E0; | |
| } | |
| .title { | |
| text-align: center; | |
| font-size: 2.2em; | |
| font-weight: bold; | |
| color: #76FF03; | |
| } | |
| .subtitle { | |
| text-align: center; | |
| font-size: 1.3em; | |
| color: #B0BEC5; | |
| } | |
| .report-container { | |
| background: #1E1E1E; | |
| padding: 15px; | |
| border-radius: 10px; | |
| border-left: 6px solid #76FF03; | |
| box-shadow: 0px 4px 8px rgba(118, 255, 3, 0.2); | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Streamlit UI | |
| st.markdown('<div class="title">π± Soil Report Analyzer</div>', unsafe_allow_html=True) | |
| st.markdown('<div class="subtitle">Upload a scanned soil report (PDF) for AI-powered analysis!</div>', 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('<div class="report-container"><b>π File Uploaded:</b> β Ready for processing</div>', 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) | |