import streamlit as st # Custom CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Main Title st.markdown('
Image Classification with Swin
', unsafe_allow_html=True) # Description st.markdown("""

Swin Transformer is a cutting-edge image classification model introduced in the paper "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" by Liu et al. The model image_classifier_swin_base_patch4_window7_224 is a Swin model, adapted from Hugging Face and curated for scalability and production-readiness using Spark NLP.

""", unsafe_allow_html=True) # Image Classification Overview st.markdown('
What is Image Classification?
', unsafe_allow_html=True) st.markdown("""

Image Classification is a computer vision task where an algorithm is trained to recognize and classify objects within images. This process involves assigning a label or category to an image based on its visual content.

How It Works

Image classification typically involves the following steps:

Why Use Image Classification?

Image classification can automate and streamline many tasks, such as:

Where to Use It

Applications of image classification span across various industries:

Importance

Image classification is crucial because it enables machines to interpret visual data, which is essential for creating intelligent systems capable of understanding and interacting with the world in a more human-like manner.

The Swin Transformer model used in this example is a state-of-the-art approach for image classification, offering advanced performance and scalability. It utilizes a hierarchical transformer architecture to capture intricate patterns and relationships within images, enhancing classification accuracy and efficiency.

""", unsafe_allow_html=True) # How to Use st.markdown('
How to Use the Model
', unsafe_allow_html=True) st.code(''' import sparknlp from sparknlp.base import * from sparknlp.annotator import * from pyspark.ml import Pipeline # Load image data imageDF = spark.read \\ .format("image") \\ .option("dropInvalid", value = True) \\ .load("src/test/resources/image/") # Define Image Assembler imageAssembler: ImageAssembler = ImageAssembler() \\ .setInputCol("image") \\ .setOutputCol("image_assembler") # Define Swin classifier imageClassifier = SwinForImageClassification \\ .pretrained("image_classifier_swin_base_patch4_window7_224") \\ .setInputCols(["image_assembler"]) \\ .setOutputCol("class") # Create pipeline pipeline = Pipeline().setStages([imageAssembler, imageClassifier]) # Apply pipeline to image data pipelineDF = pipeline.fit(imageDF).transform(imageDF) # Show results pipelineDF \\ .selectExpr("reverse(split(image.origin, '/'))[0] as image_name", "class.result") \\ .show(truncate=False) ''', language='python') # Results st.markdown('
Results
', unsafe_allow_html=True) st.markdown("""
Image Name Result
dog.JPEG [whippet]
cat.JPEG [Siamese]
bird.JPEG [peacock]
""", unsafe_allow_html=True) # Model Information st.markdown('
Model Information
', unsafe_allow_html=True) st.markdown("""
Attribute Description
Model Name image_classifier_swin_base_patch4_window7_224
Compatibility Spark NLP 4.3.0+
License Open Source
Edition Official
Input Labels [image_assembler]
Output Labels [class]
Language en
Size 108.0 MB
""", unsafe_allow_html=True) # References st.markdown('
References
', unsafe_allow_html=True) st.markdown("""
""", unsafe_allow_html=True) # Community & Support st.markdown('
Community & Support
', unsafe_allow_html=True) st.markdown("""
""", unsafe_allow_html=True)