Open xhc001 opened 1 year ago
The default mapping location for these models is the GPU.
Try adding map_location to be CPU when calling the load_from_checkpoint method
load_from_checkpoint(..., map_location=torch.device("cpu"))
Let me know if that works.
Thank you for your answer, but that doesn't seem to be the reason. I have a GPU on my computer. But when I was running 2_UC3_DL_models_inference in pycharm, there is a hint in this code that local variables are used before unassigned inputs. I can get the prediction result of cnn model by adding the following code when running cnn model: inputs = torch.cat([dynamic,static],dim=1).float(). But the predictions of the other two models no longer apply。 If I want to perform lstm or convlstm predictions individually, can I assign each inputs to a special value? As a beginner, I'm sorry I don't understand tensors and so on. `for i, (dynamic, static) in tqdm(enumerate(dataloader), total=num_iterations):
if pl_module.on_gpu:
inputs = inputs.cuda()
logits = pl_module(inputs)
preds_proba = torch.exp(logits)[:, 1]
outputs.append(preds_proba.detach().cpu())
outputs = torch.cat(outputs, dim=0)
outputs = outputs.reshape(len_y, len_x)
outputs = outputs.detach().cpu().numpy().squeeze()
return outputs`
You are totally right, some code is missing there to combine the dynamic and static inputs into one vector.
You can get the function combine_dynamic_static_inputs
from here https://github.com/Orion-AI-Lab/wildfire_forecasting/blob/main/wildfire_forecasting/models/greece_fire_models.py and call it as follows:
inputs = combine_dynamic_static_inputs(dynamic, static, None, access_mode)
if pl_module.on_gpu:
inputs = inputs.cuda()
I'll need to update this, thank you for the finding and really sorry for the trouble. I don't how this got removed from there.
By the way, although no notebooks there, if you are interested in the models, I propose that you have a look at this repo https://github.com/Orion-AI-Lab/wildfire_forecasting. It is the latest version and has been tested extensively.
Well, I have studied your model before looking at this notebook. It is very good. Thank you for your reply!
May I ask if I want to use your model to generate the wildfire risk forecast map of the Loess Plateau in China on a certain day, do I only need to collect the relevant index data of those days to make the data set? And could you share some of the methods for making the data set? Looking forward to your reply!
I don't know if the model generalizes to such a different region without retraining. All the fire drivers would exhibit very different behavior there compared to Greece. The best would be to replicate the whole process. Download historical data, make a dataset with positives and negatives, train the models, and then do inference on a particular day. Some of the data sources we used as input might not be available in your region, e.g. DEM (we used EU-DEM) or Soil Moisture (we used a dataset available in European Scale). I am sure you can find alternative products in China, but I suppose there would be a data shift from ours. As such, I do not see how a retraining can be avoided. You can find my email address here https://iprapas.github.io/ to tell me more about your project.
the models_inference always have the error : inputs = inputs.cuda() UnboundLocalError: local variable 'inputs' referenced before assignment