lolzysiu commited on
Commit
2defc24
·
verified ·
1 Parent(s): 703673c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -109,11 +109,12 @@ def forecast_solar_energy(historical_data):
109
  except Exception as e:
110
  return f"Error in forecasting: {str(e)}"
111
 
 
112
  # Read and preprocess CSV data for prediction
113
  def preprocess_csv_for_prediction(csv_file):
114
  try:
115
  # Load the data from CSV file
116
- data = pd.read_csv(Solar_Irradiance.csv) # Use csv_file.name to read the file
117
 
118
  # Ensure that the CSV has 7 columns (features) and at least 43 rows (timesteps)
119
  if data.shape[1] != 7:
@@ -136,6 +137,8 @@ def preprocess_csv_for_prediction(csv_file):
136
  except Exception as e:
137
  return f"Error in preprocessing CSV: {str(e)}"
138
 
 
 
139
  # Function to process image and forecast energy using CSV file
140
  def process_image_and_forecast(image, min_area, pixel_area, clip_limit, tile_size, panel_type,
141
  panel_length, panel_width, irradiance, electricity_rate, historical_data_csv):
@@ -181,6 +184,7 @@ def process_image_and_forecast(image, min_area, pixel_area, clip_limit, tile_siz
181
  except Exception as e:
182
  return image, f"Error: {str(e)}"
183
 
 
184
  # Gradio Interface
185
  interface = gr.Interface(
186
  fn=process_image_and_forecast,
 
109
  except Exception as e:
110
  return f"Error in forecasting: {str(e)}"
111
 
112
+ # Read and preprocess CSV data for prediction
113
  # Read and preprocess CSV data for prediction
114
  def preprocess_csv_for_prediction(csv_file):
115
  try:
116
  # Load the data from CSV file
117
+ data = pd.read_csv(csv_file.name) # Corrected from Solar_Irradiance.csv to use the file input
118
 
119
  # Ensure that the CSV has 7 columns (features) and at least 43 rows (timesteps)
120
  if data.shape[1] != 7:
 
137
  except Exception as e:
138
  return f"Error in preprocessing CSV: {str(e)}"
139
 
140
+
141
+ # Function to process image and forecast energy using CSV file
142
  # Function to process image and forecast energy using CSV file
143
  def process_image_and_forecast(image, min_area, pixel_area, clip_limit, tile_size, panel_type,
144
  panel_length, panel_width, irradiance, electricity_rate, historical_data_csv):
 
184
  except Exception as e:
185
  return image, f"Error: {str(e)}"
186
 
187
+
188
  # Gradio Interface
189
  interface = gr.Interface(
190
  fn=process_image_and_forecast,