Harsh-7300 commited on
Commit
a34ee4e
·
verified ·
1 Parent(s): 559bdd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
app.py CHANGED
@@ -80,19 +80,24 @@ def process_rooftop_image(image, geographic_bounds):
80
 
81
  # Streamlit Interface
82
  st.title("Rooftop Usable Area for Solar Panels")
83
- st.write("Upload a rooftop image to calculate the usable area for solar panels.")
84
 
85
  # File uploader for the image
86
  uploaded_file = st.file_uploader("Upload an image (PNG or JPG)", type=["png", "jpg", "jpeg"])
87
 
88
  # Input fields for geographic bounds with default values
89
- lat_min = st.number_input("Latitude Min", value=89.34, step=0.0001)
90
  lat_max = st.number_input("Latitude Max", value=89.37, step=0.0001)
91
  lon_min = st.number_input("Longitude Min", value=90.78, step=0.0001)
92
  lon_max = st.number_input("Longitude Max", value=90.80, step=0.0001)
93
 
 
 
 
 
 
94
  # Button to process the image
95
- if st.button("Calculate Usable Area"):
96
  if uploaded_file is not None:
97
  # Read the uploaded image
98
  image = np.array(Image.open(uploaded_file).convert("RGB")) # Convert PIL image to NumPy array
@@ -108,8 +113,20 @@ if st.button("Calculate Usable Area"):
108
  # Process the image
109
  final_image, usable_area = process_rooftop_image(image, geographic_bounds)
110
 
 
 
 
 
 
 
 
 
 
111
  # Display results
112
  st.image(cv2.cvtColor(final_image, cv2.COLOR_BGR2RGB), caption="Processed Image with Boundaries")
113
  st.write(f"Usable Rooftop Area for Solar Panels (excluding shadows): **{usable_area:.2f} square meters**")
 
 
 
114
  else:
115
  st.error("Please upload an image to proceed.")
 
80
 
81
  # Streamlit Interface
82
  st.title("Rooftop Usable Area for Solar Panels")
83
+ st.write("Upload a rooftop image to calculate the usable area for solar panels, panel count, total cost, and energy generation potential.")
84
 
85
  # File uploader for the image
86
  uploaded_file = st.file_uploader("Upload an image (PNG or JPG)", type=["png", "jpg", "jpeg"])
87
 
88
  # Input fields for geographic bounds with default values
89
+ lat_min = st.number_input("Latitude Min", value=89.36, step=0.0001)
90
  lat_max = st.number_input("Latitude Max", value=89.37, step=0.0001)
91
  lon_min = st.number_input("Longitude Min", value=90.78, step=0.0001)
92
  lon_max = st.number_input("Longitude Max", value=90.80, step=0.0001)
93
 
94
+ # Input fields for irradiance, panel efficiency, and sunlight hours
95
+ irradiance = st.number_input("Irradiance (W/m²)", value=200, step=1) # Default irradiance value (W/m²)
96
+ panel_efficiency = st.number_input("Panel Efficiency (%)", value=18, step=1) / 100 # Default efficiency (18%)
97
+ sunlight_hours = st.number_input("Sunlight Hours per Day", value=5, step=1) # Default 5 hours of sunlight
98
+
99
  # Button to process the image
100
+ if st.button("Calculate Usable Area and Energy Potential"):
101
  if uploaded_file is not None:
102
  # Read the uploaded image
103
  image = np.array(Image.open(uploaded_file).convert("RGB")) # Convert PIL image to NumPy array
 
113
  # Process the image
114
  final_image, usable_area = process_rooftop_image(image, geographic_bounds)
115
 
116
+ # Calculate panel count, total cost, and potential energy
117
+ panel_area = 5 * 5 # Each panel covers 25 square meters
118
+ panel_cost = 25000 # Cost per panel in INR
119
+ panel_count = usable_area // panel_area
120
+ total_cost = panel_count * panel_cost
121
+
122
+ # Calculate potential energy generation
123
+ energy_generation = usable_area * panel_efficiency * irradiance * sunlight_hours # in Wh (Watt-hours)
124
+
125
  # Display results
126
  st.image(cv2.cvtColor(final_image, cv2.COLOR_BGR2RGB), caption="Processed Image with Boundaries")
127
  st.write(f"Usable Rooftop Area for Solar Panels (excluding shadows): **{usable_area:.2f} square meters**")
128
+ st.write(f"Number of 5×5m panels that can be used: **{int(panel_count)}**")
129
+ st.write(f"Total installation cost (₹25,000 per panel): **₹{int(total_cost):,}**")
130
+ st.write(f"Total potential energy generation per day: **{energy_generation:.2f} Wh**")
131
  else:
132
  st.error("Please upload an image to proceed.")