Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use example #16

Open
kheinzz opened this issue Dec 13, 2024 · 4 comments
Open

Re-use example #16

kheinzz opened this issue Dec 13, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@kheinzz
Copy link

kheinzz commented Dec 13, 2024

Hi,

Thank you for your work and making it available.

Would it be possible to provide an example of how to perform inference using the model you provided on an image? I imagine a common use case would be applying the Cosia model to older BD_ortho images. Providing a detailed example on Google Colab could make the process much more accessible.

By advance thanks for your answer !

@agarioud
Copy link
Collaborator

Dear @kheinzz ,

Thank you for your feedback. I note the interest in a notebook, but we are currently working on a new version of the code, and this is not possible in the short term.

To perform an inference, you need to use the flair-detect module by pointing to the image of your choice (from the BD Ortho) and to the model downloaded, for example, from the HF page (https://huggingface.co/collections/IGNF/flair-models-landcover-semantic-segmentation-65bb67415a5dbabc819a95de).

The README details the arguments to be given to the flair-1-config-detect.yaml configuration file.

If, for example, you use this model: https://huggingface.co/IGNF/FLAIR-INC_rgbie_15cl_resnet34-unet
the configuration file would be, for example:

output_path: whatever
output_name: whatever

input_img_path:  ../path/to/raster/file.tif
channels: [1, 2, 3, 4, 5]

img_pixels_detection: 512
margin: 128
output_type: "argmax"
n_classes: 19


model_weights: ../path/to/model/weights/FLAIR-INC_rgbie_15cl_resnet34-unet_weights.pth
model_framework: 
    model_provider: SegmentationModelsPytorch
    
    HuggingFace:
        org_model: 
    SegmentationModelsPytorch:
        encoder_decoder: resnet34_unet


batch_size: 4
use_gpu: true
num_worker: 2

write_dataframe: False

norma_task: 
  - norm_type: custom 
    norm_means: [105.08, 110.87, 101.82, 106.38, 53.26]
    norm_stds: [52.17, 45.38, 44, 39.69, 79.3]

the you would call

flair-detect --conf=path/to/flair-1-config-detect.yaml

@agarioud agarioud added the enhancement New feature or request label Dec 16, 2024
@agarioud agarioud self-assigned this Dec 16, 2024
@kheinzz
Copy link
Author

kheinzz commented Dec 17, 2024

Hi Anatol,
Thank you for your kind and quick reply—it worked like a charm !

@axin1301
Copy link

Hi, thank you for your amazing work. I just want to run inference on an RGB image without any geometry feature. But I got error "ValueError: Unknown column geometry". DO you have any suggestion about that? Thank you

@agarioud
Copy link
Collaborator

Hello @axin1301,
flair-detect uses the rasterio library and geographical information from the input raster to produce overlapping inferences.
Hence you get this error.
Apart from modifying the code to work in the pixel space to calculate the slicing of the input raster, you could try to dummy georeference your image to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants