SwinForImageClassification - image_classifier_swin_base_patch4_window7_224_in22k

Description

Pretrained Swin model for Image Classification, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP.

Swin Transformer was introduced in the paper Swin Transformer: Hierarchical Vision Transformer using Shifted Windows by Liu et al.

Download Copy S3 URI

How to use

                
image_assembler = ImageAssembler()\
  .setInputCol("image")\
  .setOutputCol("image_assembler")

imageClassifier = SwinForImageClassification.pretrained("image_classifier_swin_base_patch4_window7_224_in22k", "en")\
  .setInputCols("image_assembler")\
  .setOutputCol("class")

pipeline = Pipeline(stages=[
  image_assembler,
  imageClassifier,
])

pipelineModel = pipeline.fit(imageDF)

pipelineDF = pipelineModel.transform(imageDF)

val imageAssembler = new ImageAssembler()
    .setInputCol("image")
    .setOutputCol("image_assembler")

val imageClassifier = SwinForImageClassification
    .pretrained("image_classifier_swin_base_patch4_window7_224_in22k", "en")
    .setInputCols("image_assembler") 
    .setOutputCol("class") 

val pipeline = new Pipeline().setStages(Array(imageAssembler, imageClassifier))

val pipelineModel = pipeline.fit(imageDF)

val pipelineDF = pipelineModel.transform(imageDF)

Model Information

Model Name: image_classifier_swin_base_patch4_window7_224_in22k
Compatibility: Spark NLP 4.3.0+
License: Open Source
Edition: Official
Input Labels: [image_assembler]
Output Labels: [class]
Language: en
Size: 825.5 MB

References

https://huggingface.co/microsoft/swin-base-patch4-window7-224-in22k