allenai / satlas-super-resolution

Apache License 2.0
220 stars 24 forks source link

Inferences: `network_g`, ['path']['pretrain_network_g'], and ['path']['param_key_g'] #44

Open rodolfolotte opened 1 month ago

rodolfolotte commented 1 month ago

First, I would like to thank you for sharing this amazing content, a well-documented and easy-to-approach solution.

I start to set my environment to apply the inference over CBERS-4A images. The idea is only to see if the S2NAIP pretrained would perform ok over CBERS-4A, without training. Then, I downloaded the small_val_set, and test_set and placed them in the project' root folder. Finally, I have tried to perform:

python -m ssr.infer -opt ssr/options/infer_example.yml

with a few changes in infer_example.yml (i.e. the data_dir param).

Question 1. The error seems to be with the absence of experiments/sample_net_g.pth and param_key_g: params_ema. I also have downloaded the satlas_rrdbnet.pth, and point to it. But it does not work either. Could you give me a hint how to proper set the params in path?

Question 2. Considering I want to perform another training using the same approach, but using CBERS-4A and UAV samples. How should I transform the training dataset?

Thank you so much! Great work!

piperwolters commented 3 weeks ago

Hi! Thank you for your interest in this work.

My initial thought is that the models won't do well on a new image modality without any finetuning. I found that finetuning on even ~100 samples substantially improved the quality of outputs for new modalities.

1) You will want to download model weights from this table, and then update the experiments/sample_net_g.pth path to the path pointing to the downloaded weights (ex. 'path/to/weights/on/your/machine/weights.pth').

2) I would recommend loading in some of the pretrained weights (using the same steps at 1.), formatting your data in the required format (see docs here), and making a config that specifies the correct paths to your data and the weights, and then running the training script.

The most important thing to getting this to work with your data out of the box is the formatting of the dataset. The existing dataset code expects something like: -root_dir --sentinel2 ----tile ------tci.png ------b08.png ------... --naip ----image_uuid ------tile --------rgb.png

where tile refers to its location in a 2^17 x 2^17 Web-Mercator grid.

Of course, you may make changes to the dataset file, to cater to your specific setup if you don't want to totally reformat your data structure.

Hope this helps!