Mismatch between Hugging Face Pretrained Model Description and GitHub Implementation
I have noticed a discrepancy between the pretrained model mentioned on the Hugging Face website and its actual implementation available in the GitHub repository. Specifically:
Hugging Face Model Page: https://huggingface.co/IGNF/FLAIR-INC_rgbie_15cl_resnet34-unet/blob/main/FLAIR-INC_rgbie_15cl_resnet34-unet_weights.pth
Error:
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Traceback (most recent call last):
File "\?\C:\Users\Rajaram\anaconda3\envs\GPU\Scripts\flair-detect-script.py", line 33, in
Hello @rajaram6052150 The pre-trained models available right now on our HF page have been trained with segmentation-models-pytorch. This might indeed not be clear for now, we will update the model cards and model names when releasing pre-trained models trained with HF. So for now your config file should use something like :
model_weights: ../FLAIR-INC_rgbie_15cl_resnet34-unet_weights.pth
model_framework:
model_provider: SegmentationModelsPytorch
HuggingFace:
org_model:
SegmentationModelsPytorch:
encoder_decoder: resnet34_unet
Hello @agarioud ,
Thank you for the clarification regarding the pre-trained models. However, I have checked the specified path in the GitHub repository, and it appears that the file FLAIR-INC_rgbie_15cl_resnet34-unet_weights.pth is not present there.
Could you please provide the correct path or a link to download the pre-trained model file? It would be very helpful for continuing with the setup.
Thank you!
Best regards, Rajaram
You had the right link : https://huggingface.co/IGNF/FLAIR-INC_rgbie_15cl_resnet34-unet/blob/main/FLAIR-INC_rgbie_15cl_resnet34-unet_weights.pth Once downloaded locally, you should ajust the 'model_weights' path from the config file to point it.
Thank you for help sir @agarioud . Sorry to bother you again . I’ve successfully set up and run inference using the FLAIR-INC_rgbie_15cl_resnet34-unet model after addressing the issue with the model_weights path. However, the output images are all coming out completely black.
Here are the details of my setup and problem:
Setup: Model Weights Path: Correctly set to the downloaded weights file from Hugging Face. Input Image: Path: Set to a georeferenced raster image. Metadata: Driver: GTiff Dtype: uint8 Number of Bands: 5 Image Shape: (5, 512, 512) CRS: EPSG:2154 Configuration Parameters: Output Type: argmax Normalization: Custom Image Size for Detection: 512 Overlap Margin: 128 Issue: Observation: The output raster images are completely black for all processed images. Error Message: No errors are reported during execution, and the model successfully loads and performs inference without issues.
@rajaram6052150, the flair-detect command is meant to infer over a 'large' area with overlap in inferences. If you image is 512*512 and img_pixels_detection is also 512 but with 128 overlap it may yield some inconsistencies. Also, the output raster are 'black' but do they contain values ?
Big thanks to you for the guidance sir @agarioud . It turns out that the black images do indeed contain values, representing different classes, and the segmentation results are accurate. Your suggestion helped us identify this.
I also wanted to ask: Will this implementation work with JPG or PNG images as well, or do I need to modify the code for those formats?
Glad it worked out @rajaram6052150, happy to help. flair-detect won't work with JPG/PNG images as it is meant to work with georeferenced inputs. I haven't planned to add support to this in the near future so you might wan't to either convert your inputs or indeed modify the code. Best,