import streamlit as st import pandas as pd import google.generativeai as genai import os from dotenv import load_dotenv # Load environment variables load_dotenv() # Set page configuration st.set_page_config(page_title="☀️AI-Based Solar Project Estimation Tool", layout="centered") # Load solar data @st.cache_data def load_data(): df = pd.read_csv('https://huggingface.co/spaces/MLDeveloper/AI_based_Solar_Project_Estimation_Tool/resolve/main/solar_data_india_2024.csv') return df df = load_data() # Constants TARIFF_RATE = 7 # ₹7 per kWh ROOFTOP_CONVERSION_FACTOR = 0.10 # 0.10 kW per sq meter # UI - Form st.title("☀️AI-Based Solar Project Estimation Tool") st.write("### Enter Your Details Below:") with st.form("solar_form"): state_options = df['State'].dropna().unique() location = st.selectbox("Select your State", options=sorted(state_options)) # Fixed line: showing only bolded "Rooftop Solar" heading st.markdown("### **Rooftop Solar**") roof_size = st.number_input("Enter your roof size (in sq meters)", min_value=1) electricity_bill = st.number_input("Enter your monthly electricity bill (₹)", min_value=0) submitted = st.form_submit_button("Get Estimate") # Calculate directly if submitted and location: state_data = df[df['State'].str.contains(location, case=False)].iloc[0] if state_data is not None: ghi = state_data['Avg_GHI (kWh/m²/day)'] solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)'] system_size_kw = round(roof_size * ROOFTOP_CONVERSION_FACTOR, 2) estimated_daily_output = round(system_size_kw * ghi, 2) total_system_cost = round(system_size_kw * solar_cost_per_kw, 2) monthly_savings = round(estimated_daily_output * 30 * TARIFF_RATE, 2) payback_period = round(total_system_cost / (monthly_savings * 12), 2) # Display Results st.subheader("🔹 Solar Project Estimate") st.write(f"**Estimated solar system size in kW**: {system_size_kw}") st.write(f"**Estimated daily solar output in kWh**: {estimated_daily_output}") st.write(f"**Total system cost in ₹**: {total_system_cost}") st.write(f"**Monthly savings in ₹**: {monthly_savings}") st.write(f"**Payback period in years**: {payback_period}") st.info("Note: Tariff assumed ₹7/kWh. Actual payback may vary based on location, grid policy, and maintenance.") else: st.error("State data not found. Please try a valid state.") else: st.warning("Please complete all fields to get your estimate.")