Time Series Forecasting
Keras
English
deeplearning
ConvoLSTM
Cloudcover-prediction
Satellite
data
dataanalysis
timeseries
code
tensorflow
machinelearning
Instructions to use Hrishi-2003/Cloud-Cover-Nowcasting with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Hrishi-2003/Cloud-Cover-Nowcasting with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Hrishi-2003/Cloud-Cover-Nowcasting") - Notebooks
- Google Colab
- Kaggle
Download train.py from Hrishi-2003/Cloud-Cover-Nowcasting: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/Hrishi-2003/Cloud-Cover-Nowcasting/resolve/main/train.py
- Command line
-
hf download hf://Hrishi-2003/Cloud-Cover-Nowcasting/train.py
-
curl -L -o train.py https://huggingface.co/Hrishi-2003/Cloud-Cover-Nowcasting/resolve/main/train.py
1.62 kB
| import numpy as np | |
| from sklearn.model_selection import train_test_split | |
| from tensorflow.keras.optimizers import Adam | |
| from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping | |
| from data_loader import load_images_from_folder, create_sequences, create_shifted_frames | |
| from model_builder import build_residual_convlstm_model_seq2seq | |
| # Parameters | |
| folder_path = "/home/hrishikesh2003/Data/DataNewApproch" | |
| image_size = (200, 200) | |
| sequence_length = 5 | |
| batch_size = 4 | |
| epochs = 20 | |
| # Load and preprocess data | |
| dataset = load_images_from_folder(folder_path, img_size=image_size) | |
| dataset = np.expand_dims(dataset, axis=-1) | |
| sequences = create_sequences(dataset, sequence_length) | |
| # Split data | |
| train_sequences, val_sequences = train_test_split(sequences, test_size=0.1, shuffle=False) | |
| x_train, y_train = create_shifted_frames(train_sequences) | |
| x_val, y_val = create_shifted_frames(val_sequences) | |
| # Build model | |
| model = build_residual_convlstm_model_seq2seq(input_shape=(sequence_length - 1, *image_size, 1)) | |
| model.compile(optimizer=Adam(learning_rate=0.001), loss='mean_absolute_error') | |
| # Callbacks | |
| checkpoint = ModelCheckpoint( | |
| 'best_model.keras', monitor='val_loss', save_best_only=True, mode='min', verbose=1 | |
| ) | |
| early_stopping = EarlyStopping(monitor='val_loss', patience=20, mode='min', verbose=1) | |
| # Train model | |
| if x_train.shape[0] > 0 and y_train.shape[0] > 0: | |
| model.fit( | |
| x_train, y_train, | |
| batch_size=batch_size, | |
| epochs=epochs, | |
| validation_data=(x_val, y_val), | |
| callbacks=[checkpoint, early_stopping] | |
| ) | |
| else: | |
| print("Not enough training data to train the model.") | |