Harsh-7300 commited on
Commit
96aeb3b
·
verified ·
1 Parent(s): fdcd9fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -1,13 +1,24 @@
 
 
 
 
1
  import cv2
2
  import numpy as np
3
  import pandas as pd
4
  import gradio as gr
5
- from keras.models import load_model
6
  from sklearn.preprocessing import OneHotEncoder, StandardScaler
7
- from tensorflow.keras.losses import MeanSquaredError # Importing the built-in MSE loss
8
 
9
- # Load the pre-trained model
10
- loaded_model = load_model('solar_irradiance_model.h5')
 
 
 
 
 
 
 
 
 
11
 
12
  # Load the dataset for encoder and scaler setup
13
  data = pd.read_csv('Solar_Irradiance.csv')
@@ -23,6 +34,8 @@ scaler = StandardScaler()
23
  numerical_features = features[['Latitude', 'Longitude', 'Panel_Capacity(W)', 'Panel_Efficiency', 'Wind_Speed(km/h)', 'Cloud_Cover(%)', 'temperature (°f)']]
24
  scaler.fit(numerical_features)
25
 
 
 
26
  # Shadow Removal Function
27
  def remove_shadows(image):
28
  """Removes shadows using illumination normalization."""
 
1
+ import os
2
+ import tensorflow as tf
3
+ from keras.models import load_model
4
+ from tensorflow.keras.losses import MeanSquaredError
5
  import cv2
6
  import numpy as np
7
  import pandas as pd
8
  import gradio as gr
 
9
  from sklearn.preprocessing import OneHotEncoder, StandardScaler
 
10
 
11
+ # Disable GPU if not needed
12
+ os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
13
+
14
+ # Load and compile the model
15
+ def load_and_compile_model(model_path):
16
+ model = load_model(model_path)
17
+ model.compile(optimizer='adam', loss=MeanSquaredError())
18
+ return model
19
+
20
+ # Load the model and compile it
21
+ loaded_model = load_and_compile_model('solar_irradiance_model.h5')
22
 
23
  # Load the dataset for encoder and scaler setup
24
  data = pd.read_csv('Solar_Irradiance.csv')
 
34
  numerical_features = features[['Latitude', 'Longitude', 'Panel_Capacity(W)', 'Panel_Efficiency', 'Wind_Speed(km/h)', 'Cloud_Cover(%)', 'temperature (°f)']]
35
  scaler.fit(numerical_features)
36
 
37
+ # The rest of your code continues...
38
+
39
  # Shadow Removal Function
40
  def remove_shadows(image):
41
  """Removes shadows using illumination normalization."""