Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,14 @@ import joblib # For loading the saved preprocessing objects
|
|
| 6 |
|
| 7 |
# Load your pre-trained model
|
| 8 |
model = load_model('crack_prediction-2.h5')
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Load the preprocessing objects
|
| 11 |
poly = PolynomialFeatures(degree=5, include_bias=False)
|
| 12 |
scaler = StandardScaler()
|
|
@@ -16,17 +23,12 @@ def preprocess_input(flange_width, beam_width, geometric_factor):
|
|
| 16 |
"""
|
| 17 |
Preprocess the input data: apply polynomial features and then scale.
|
| 18 |
"""
|
| 19 |
-
# Create input array
|
| 20 |
-
input_data = np.reshape( [flange_width, beam_width, geometric_factor], (1,-1))
|
| 21 |
|
| 22 |
# # Apply Polynomial Features
|
| 23 |
-
|
| 24 |
-
X_test_poly = poly.fit_transform(input_data)
|
| 25 |
|
| 26 |
# Standardize the polynomial features
|
| 27 |
-
|
| 28 |
-
X_train_poly_scaled = scaler.fit_transform(X_test_poly)
|
| 29 |
-
scaled_features = scaler.transform(X_train_poly_scaled)
|
| 30 |
|
| 31 |
return scaled_features
|
| 32 |
|
|
|
|
| 6 |
|
| 7 |
# Load your pre-trained model
|
| 8 |
model = load_model('crack_prediction-2.h5')
|
| 9 |
+
with open('poly_features.pkl', 'rb') as f:
|
| 10 |
+
poly_loaded = pickle.load(f)
|
| 11 |
|
| 12 |
+
# Load the StandardScaler object
|
| 13 |
+
with open('standard_scaler.pkl', 'rb') as f:
|
| 14 |
+
scaler_loaded = pickle.load(f)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
# Load the preprocessing objects
|
| 18 |
poly = PolynomialFeatures(degree=5, include_bias=False)
|
| 19 |
scaler = StandardScaler()
|
|
|
|
| 23 |
"""
|
| 24 |
Preprocess the input data: apply polynomial features and then scale.
|
| 25 |
"""
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# # Apply Polynomial Features
|
| 28 |
+
X_test_poly = poly_loaded.transform([[flange_width, beam_width, geometric_factor]])
|
|
|
|
| 29 |
|
| 30 |
# Standardize the polynomial features
|
| 31 |
+
scaled_features = scaler_loaded.transform(X_train_poly_scaled)
|
|
|
|
|
|
|
| 32 |
|
| 33 |
return scaled_features
|
| 34 |
|