diff --git a/.streamlit/config.toml b/.streamlit/config.toml new file mode 100644 index 0000000000000000000000000000000000000000..1351925fe878f35a9e31ac01757b8a4853757090 --- /dev/null +++ b/.streamlit/config.toml @@ -0,0 +1,3 @@ +[theme] +base="light" +primaryColor="#29B4E8" diff --git a/Demo.py b/Demo.py new file mode 100644 index 0000000000000000000000000000000000000000..3297b794a74e9a5f229438bee939bf301fd01c2f --- /dev/null +++ b/Demo.py @@ -0,0 +1,127 @@ +import streamlit as st +import sparknlp +import os +import pandas as pd + +from sparknlp.base import * +from sparknlp.annotator import * +from pyspark.ml import Pipeline +from sparknlp.pretrained import PretrainedPipeline +from streamlit_tags import st_tags + +# Page configuration +st.set_page_config( + layout="wide", + initial_sidebar_state="auto" +) + +# CSS for styling +st.markdown(""" + +""", unsafe_allow_html=True) + +@st.cache_resource +def init_spark(): + return sparknlp.start() + +@st.cache_resource +def create_pipeline(model): + image_assembler = ImageAssembler() \ + .setInputCol("image") \ + .setOutputCol("image_assembler") + + image_classifier = ViTForImageClassification \ + .pretrained(model) \ + .setInputCols("image_assembler") \ + .setOutputCol("class") + + pipeline = Pipeline(stages=[ + image_assembler, + image_classifier, + ]) + return pipeline + +def fit_data(pipeline, data): + empty_df = spark.createDataFrame([['']]).toDF('text') + model = pipeline.fit(empty_df) + light_pipeline = LightPipeline(model) + annotations_result = light_pipeline.fullAnnotateImage(data) + return annotations_result[0]['class'][0].result + +def save_uploadedfile(uploadedfile): + filepath = os.path.join(IMAGE_FILE_PATH, uploadedfile.name) + with open(filepath, "wb") as f: + if hasattr(uploadedfile, 'getbuffer'): + f.write(uploadedfile.getbuffer()) + else: + f.write(uploadedfile.read()) + +# Sidebar content +model_list = ['image_classifier_vit_base_cats_vs_dogs', 'image_classifier_vit_base_patch16_224', 'image_classifier_vit_CarViT', 'image_classifier_vit_base_beans_demo', 'image_classifier_vit_base_food101', 'image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10'] +model = st.sidebar.selectbox( + "Choose the pretrained model", + model_list, + help="For more info about the models visit: https://sparknlp.org/models" +) + +# Set up the page layout +st.markdown(f'
ViT for Image Classification
', unsafe_allow_html=True) +# st.markdown(f'

{sub_title}

', unsafe_allow_html=True) + +# Reference notebook link in sidebar +link = """ + + Open In Colab + +""" +st.sidebar.markdown('Reference notebook:') +st.sidebar.markdown(link, unsafe_allow_html=True) + +# Load examples +IMAGE_FILE_PATH = f"/content/sparknlp VIT Image Classification/inputs/{model}" +image_files = sorted([file for file in os.listdir(IMAGE_FILE_PATH) if file.split('.')[-1]=='png' or file.split('.')[-1]=='jpg' or file.split('.')[-1]=='JPEG' or file.split('.')[-1]=='jpeg']) + +st.subheader("This model identifies image classes using the vision transformer (ViT).") + +img_options = st.selectbox("Select an image", image_files) +uploadedfile = st.file_uploader("Try it for yourself!") + +if uploadedfile: + file_details = {"FileName":uploadedfile.name,"FileType":uploadedfile.type} + save_uploadedfile(uploadedfile) + selected_image = f"{IMAGE_FILE_PATH}/{uploadedfile.name}" +elif img_options: + selected_image = f"{IMAGE_FILE_PATH}/{img_options}" + +st.subheader('Classified Image') + +image_size = st.slider('Image Size', 400, 1000, value=400, step = 100) + +try: + st.image(f"{IMAGE_FILE_PATH}/{selected_image}", width=image_size) +except: + st.image(selected_image, width=image_size) + +st.subheader('Classification') + +spark = init_spark() +Pipeline = create_pipeline(model) +output = fit_data(Pipeline, selected_image) + +st.markdown(f'This document has been classified as : **{output}**') \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9bfdb55fe4c4a7afeedff8f137e4b25c06115433 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,70 @@ +# Download base image ubuntu 18.04 +FROM ubuntu:18.04 + +# Set environment variables +ENV NB_USER jovyan +ENV NB_UID 1000 +ENV HOME /home/${NB_USER} + +# Install required packages +RUN apt-get update && apt-get install -y \ + tar \ + wget \ + bash \ + rsync \ + gcc \ + libfreetype6-dev \ + libhdf5-serial-dev \ + libpng-dev \ + libzmq3-dev \ + python3 \ + python3-dev \ + python3-pip \ + unzip \ + pkg-config \ + software-properties-common \ + graphviz \ + openjdk-8-jdk \ + ant \ + ca-certificates-java \ + && apt-get clean \ + && update-ca-certificates -f; + +# Install Python 3.8 and pip +RUN add-apt-repository ppa:deadsnakes/ppa \ + && apt-get update \ + && apt-get install -y python3.8 python3-pip \ + && apt-get clean; + +# Set up JAVA_HOME +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ +RUN mkdir -p ${HOME} \ + && echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> ${HOME}/.bashrc \ + && chown -R ${NB_UID}:${NB_UID} ${HOME} + +# Create a new user named "jovyan" with user ID 1000 +RUN useradd -m -u ${NB_UID} ${NB_USER} + +# Switch to the "jovyan" user +USER ${NB_USER} + +# Set home and path variables for the user +ENV HOME=/home/${NB_USER} \ + PATH=/home/${NB_USER}/.local/bin:$PATH + +# Set the working directory to the user's home directory +WORKDIR ${HOME} + +# Upgrade pip and install Python dependencies +RUN python3.8 -m pip install --upgrade pip +COPY requirements.txt /tmp/requirements.txt +RUN python3.8 -m pip install -r /tmp/requirements.txt + +# Copy the application code into the container at /home/jovyan +COPY --chown=${NB_USER}:${NB_USER} . ${HOME} + +# Expose port for Streamlit +EXPOSE 7860 + +# Define the entry point for the container +ENTRYPOINT ["streamlit", "run", "Demo.py", "--server.port=7860", "--server.address=0.0.0.0"] \ No newline at end of file diff --git a/inputs/image_classifier_vit_CarViT/image-1.png b/inputs/image_classifier_vit_CarViT/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..e2ed29de1d3401f5aaadc7725304fabe7091f9e6 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-1.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-10.png b/inputs/image_classifier_vit_CarViT/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..f599356887b938d8d6c38271481779be6cc2de23 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-10.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-2.png b/inputs/image_classifier_vit_CarViT/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..302818fb77baf40c1a344fb48eaca88f3389b3a3 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-2.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-3.png b/inputs/image_classifier_vit_CarViT/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..66876cd03a2420f4f65074eaa639e11fc54df079 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-3.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-4.png b/inputs/image_classifier_vit_CarViT/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..8df88428b2a38d8738fc1531b55f3d4ceb76f158 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-4.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-5.png b/inputs/image_classifier_vit_CarViT/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..c80866807ddec8a1c7ff1b99c73d14e3b7a11188 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-5.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-6.png b/inputs/image_classifier_vit_CarViT/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..7acbad83001599c94d8e43d95ad58ac3a8e73646 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-6.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-7.png b/inputs/image_classifier_vit_CarViT/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..575139d253f4850f00a7a44c8be6f770d026d741 Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-7.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-8.png b/inputs/image_classifier_vit_CarViT/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..aeacb41b7f3c4deb512b7b489520faae77f4613a Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-8.png differ diff --git a/inputs/image_classifier_vit_CarViT/image-9.png b/inputs/image_classifier_vit_CarViT/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..f123d68391853a5db48588a74715f541bb8e11cc Binary files /dev/null and b/inputs/image_classifier_vit_CarViT/image-9.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-1.png b/inputs/image_classifier_vit_base_beans_demo/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..3e4acf665eac7dfa6b535eba18288851fe9665a8 Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-1.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-10.png b/inputs/image_classifier_vit_base_beans_demo/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..93a090b2a199cfca817f26a6b7ded05b2b0069de Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-10.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-2.png b/inputs/image_classifier_vit_base_beans_demo/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..617bc0c931a53d4182b6318aa2473d18007dad7d Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-2.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-3.png b/inputs/image_classifier_vit_base_beans_demo/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1b8e1554ef97679ac4efdbe3efe24c26fbeb9c25 Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-3.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-4.png b/inputs/image_classifier_vit_base_beans_demo/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..5e8ec1626ae955e9d151890a80dd751580e61d3c Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-4.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-5.png b/inputs/image_classifier_vit_base_beans_demo/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..ac0f5bb4e19ffcb442243a016152a598ab69f1cd Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-5.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-6.png b/inputs/image_classifier_vit_base_beans_demo/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..09caf2db00a208e865be0d9e46b97494e00c4b90 Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-6.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-7.png b/inputs/image_classifier_vit_base_beans_demo/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..1ea1d0e0363846cde6e45410fb16c7b478707c03 Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-7.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-8.png b/inputs/image_classifier_vit_base_beans_demo/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..2ebaaa6ae54eacc9b486905f37b14ba061a49a81 Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-8.png differ diff --git a/inputs/image_classifier_vit_base_beans_demo/image-9.png b/inputs/image_classifier_vit_base_beans_demo/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..e584c20438fd594b5cfe790a3daab345830f30cd Binary files /dev/null and b/inputs/image_classifier_vit_base_beans_demo/image-9.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-1.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..83161d56613f1d43681fee496652a3e97e78ce47 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-1.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-10.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..06336c1d8b400d6dea9aa6d43246a65d52402610 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-10.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-2.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..2e26f97795494ff58bef9c5b64d0bc896da8f812 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-2.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-3.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..8e823399c39d5bf9961451f0296f9864cf0985c1 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-3.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-4.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..8ac916f5f64cafda01ae2993150499659ae36a38 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-4.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-5.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..e090ec944593fd4cd9c7f79cfc5b07363c13631b Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-5.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-6.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..8e6743ff38cc6330fa48590ededd413793d1df11 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-6.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-7.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..fb056a39def46f879c4ae25453b6d87ca6e64642 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-7.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-8.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..d26aa03d1f6f702f5a3c74b41598cca9d797c716 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-8.png differ diff --git a/inputs/image_classifier_vit_base_cats_vs_dogs/image-9.png b/inputs/image_classifier_vit_base_cats_vs_dogs/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..dbcae34215207cc97c57b94a85cda0f21f54bb11 Binary files /dev/null and b/inputs/image_classifier_vit_base_cats_vs_dogs/image-9.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-1.png b/inputs/image_classifier_vit_base_food101/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..883d153cb6020a2eca702dadfeb22c87e2421265 Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-1.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-10.png b/inputs/image_classifier_vit_base_food101/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..b006bf667dc8f6f24aa683cee01dc6003b3d122b Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-10.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-2.png b/inputs/image_classifier_vit_base_food101/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..44bf60d1d512ef5adeee2bb34d85a05ea708a7a6 Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-2.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-3.png b/inputs/image_classifier_vit_base_food101/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..945fe5f78ab3bb02bcbab744ef6ce04559590d4a Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-3.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-4.png b/inputs/image_classifier_vit_base_food101/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..915bbade5c5aae79b4419e5730426b9952b75cdc Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-4.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-5.png b/inputs/image_classifier_vit_base_food101/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..de6bea92a7fe4afd09d78f4262f554980cf217ee Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-5.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-6.png b/inputs/image_classifier_vit_base_food101/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..269e830f395f8cf50456136d6f0fcd442ad6dfdf Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-6.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-7.png b/inputs/image_classifier_vit_base_food101/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..cf13e6a107cf83587961131bde0777d477386af8 Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-7.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-8.png b/inputs/image_classifier_vit_base_food101/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..aee6a00dbd29454b4961078ca14b94908c01e264 Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-8.png differ diff --git a/inputs/image_classifier_vit_base_food101/image-9.png b/inputs/image_classifier_vit_base_food101/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..88fd8726711fa7331e4866452b2a85be63335cab Binary files /dev/null and b/inputs/image_classifier_vit_base_food101/image-9.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-1.png b/inputs/image_classifier_vit_base_patch16_224/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..8efdfca8fe2e6c26d380dbfa469704c864290afd Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-1.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-10.png b/inputs/image_classifier_vit_base_patch16_224/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..b55ce7f08bcc552bac02ae692a25157cca700b89 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-10.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-11.png b/inputs/image_classifier_vit_base_patch16_224/image-11.png new file mode 100644 index 0000000000000000000000000000000000000000..30df504d4793e44886a146287c3874386df583a3 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-11.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-3.png b/inputs/image_classifier_vit_base_patch16_224/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..b8e1ea99f0daa2b3c0d2ea4d975c948178d53f7d Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-3.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-4.png b/inputs/image_classifier_vit_base_patch16_224/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..9e5bbb3a91c351d0c01be692f31c396d79928f69 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-4.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-5.png b/inputs/image_classifier_vit_base_patch16_224/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..9ebf560a8d1e24ebaa2228f19a3c9b192376a8e7 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-5.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-6.png b/inputs/image_classifier_vit_base_patch16_224/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..308035aef692383afaf80d3263fb6987bc640d26 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-6.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-7.png b/inputs/image_classifier_vit_base_patch16_224/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..a3a72132bd1ac8d333469b9b7822103a15aa6fd3 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-7.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-8.png b/inputs/image_classifier_vit_base_patch16_224/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..e131e8ecdf32c3f751ab0f7b2e5f002683babda2 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-8.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224/image-9.png b/inputs/image_classifier_vit_base_patch16_224/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..db21bacd3664de08b53ee189c2cd701aadb729b0 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224/image-9.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-1.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..5fccf20b42b83e100715f75f23f16f264532412d Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-1.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-10.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-10.png new file mode 100644 index 0000000000000000000000000000000000000000..897273476fe095d16142037c65a13bda1805fff9 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-10.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-2.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..0b071c625ac646c2628dc8fa0b51b592421d5465 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-2.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-3.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-3.png new file mode 100644 index 0000000000000000000000000000000000000000..a6ba40de3971be81ad707a38b6bc5c939d1ba9a0 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-3.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-4.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-4.png new file mode 100644 index 0000000000000000000000000000000000000000..4c49a9af7ef696ce9b6d8d5c94f82855f4f6a085 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-4.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-5.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-5.png new file mode 100644 index 0000000000000000000000000000000000000000..c08eb831dffa22771463aed856fcba0a53fb6e80 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-5.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-6.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-6.png new file mode 100644 index 0000000000000000000000000000000000000000..fe1855576745da197fd02818ca7e963a4e4f6c41 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-6.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-7.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-7.png new file mode 100644 index 0000000000000000000000000000000000000000..2ab404abf1f873e37cc57a7e1cf70ded1809f0ac Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-7.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-8.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-8.png new file mode 100644 index 0000000000000000000000000000000000000000..e9e34cf013f4a8db3b8581df7fde7825fa4701d6 Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-8.png differ diff --git a/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-9.png b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-9.png new file mode 100644 index 0000000000000000000000000000000000000000..0f89af2194b62067efd51553ab5fcc62e6c0c5db Binary files /dev/null and b/inputs/image_classifier_vit_base_patch16_224_in21k_finetuned_cifar10/image-9.png differ diff --git a/pages/Workflow & Model Overview.py b/pages/Workflow & Model Overview.py new file mode 100644 index 0000000000000000000000000000000000000000..5fb37ad1029bdb39f00d8594b3b4497e949c08c4 --- /dev/null +++ b/pages/Workflow & Model Overview.py @@ -0,0 +1,263 @@ +import streamlit as st + +# Custom CSS for better styling +st.markdown(""" + +""", unsafe_allow_html=True) + +# Main Title +st.markdown('
Image Classification with ViT
', unsafe_allow_html=True) + +# Description +st.markdown(""" +
+

ViT (Vision Transformer) is a state-of-the-art image classification model developed by Google. The model image_classifier_vit_base_patch16_224 is a ViT model, adapted from Hugging Face and curated for scalability and production-readiness using Spark NLP.

+

This model was imported from Hugging Face Transformers: ViT Model on Hugging Face

+
+""", 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 ViT (Vision Transformer) model used in this example is a state-of-the-art approach for image classification, offering advanced performance and scalability. It utilizes transformer architecture to capture intricate patterns and relationships within images, enhancing classification accuracy and efficiency.

+
+""", unsafe_allow_html=True) + +st.write("") +with st.expander("View Predicted Entities"): + st.markdown(""" +
+

+ turnstile, damselfly, mixing bowl, sea snake, cockroach, roach, buckle, beer glass, bulbul, lumbermill, sawmill, whippet, Australian terrier, television, television system, hoopskirt, crinoline, horse cart, horse-cart, guillotine, malamute, malemute, Alaskan malamute, coyote, prairie wolf, brush wolf, Canis latrans, colobus, colobus monkey, hognose snake, puff adder, sand viper, sock, burrito, printer, bathing cap, swimming cap, chiton, coat-of-mail shell, sea cradle, polyplacophore, Rottweiler, cello, violoncello, pitcher, ewer, computer keyboard, keypad, bow, peacock, ballplayer, baseball player, refrigerator, icebox, solar dish, solar collector, solar furnace, passenger car, coach, carriage, African chameleon, Chamaeleo chamaeleon, oboe, hautboy, hautbois, toyshop, Leonberg, howler monkey, howler, bluetick, African elephant, Loxodonta africana, American lobster, Northern lobster, Maine lobster, Homarus americanus, combination lock, black-and-tan coonhound, bonnet, poke bonnet, harvester, reaper, Appenzeller, iron, smoothing iron, electric locomotive, lycaenid, lycaenid butterfly, sandbar, sand bar, Cardigan, Cardigan Welsh corgi, pencil sharpener, jean, blue jean, denim, backpack, back pack, knapsack, packsack, rucksack, haversack, monitor, ice cream, icecream, apiary, bee house, water jug, American coot, marsh hen, mud hen, water hen, Fulica americana, ground beetle, carabid beetle, jigsaw puzzle, ant, emmet, pismire, wreck, kuvasz, gyromitra, Ibizan hound, Ibizan Podenco, brown bear, bruin, Ursus arctos, bolo tie, bolo, bola tie, bola, Pembroke, Pembroke Welsh corgi, French bulldog, prison, prison house, ballpoint, ballpoint pen, ballpen, Biro, stage, airliner, dogsled, dog sled, dog sleigh, redshank, Tringa totanus, menu, Indian cobra, Naja naja, swab, swob, mop, window screen, brain coral, artichoke, globe artichoke, loupe, jeweler's loupe, loudspeaker, speaker, speaker unit, loudspeaker system, speaker system, panpipe, pandean pipe, syrinx, wok, croquet ball, plate, scoreboard, Samoyed, Samoyede, ocarina, sweet potato, beaver, borzoi, Russian wolfhound, horizontal bar, high bar, stretcher, seat belt, seatbelt, obelisk, forklift, feather boa, boa, frying pan, frypan, skillet, barbershop, hamper, face powder, Siamese cat, Siamese, ladle, dingo, warrigal, warragal, Canis dingo, mountain tent, head cabbage, echidna, spiny anteater, anteater, Polaroid camera, Polaroid Land camera, dumbbell, espresso, notebook, notebook computer, Norfolk terrier, binoculars, field glasses, opera glasses, carpenter's kit, tool kit, moving van, catamaran, tiger beetle, bikini, two-piece, Siberian husky, studio couch, day bed, bulletproof vest, lawn mower, mower, promontory, headland, head, foreland, soap dispenser, vulture, dam, dike, dyke, brambling, Fringilla montifringilla, toilet tissue, toilet paper, bathroom tissue, ringlet, ringlet butterfly, tiger cat, mobile home, manufactured home, Norwich terrier, little blue heron, Egretta caerulea, English setter, Tibetan mastiff, rocking chair, rocker, mask, maze, labyrinth, bookcase, viaduct, sweatshirt, plow, plough, basenji, typewriter keyboard, Windsor tie, coral fungus, desktop computer, Kerry blue terrier, Angora, Angora rabbit, can opener, tin opener, shield, buckler, triumphal arch, horned viper, cerastes, sand viper, horned asp, Cerastes cornutus, miniature schnauzer, tape player, jaguar, panther, Panthera onca, Felis onca, hook, claw, file, file cabinet, filing cabinet, chime, bell, gong, shower curtain, window shade, acoustic guitar, gas pump, gasoline pump, petrol pump, island dispenser, cicada, cicala, Petri dish, paintbrush, banana, chickadee, mountain bike, all-terrain bike, off-roader, lighter, light, igniter, ignitor, oil filter, cab, hack, taxi, taxicab, Christmas stocking, rugby ball, black widow, Latrodectus mactans, bustard, fiddler crab, web site, website, internet site, site, chocolate sauce, chocolate syrup, chainlink fence, fireboat, cocktail shaker, airship, dirigible, projectile, missile, bagel, beigel, screwdriver, oystercatcher, oyster catcher, pot, flowerpot, water bottle, Loafer, drumstick, soccer ball, cairn, cairn terrier, padlock, tow truck, tow car, wrecker, bloodhound, sleuthhound, punching bag, punch bag, punching ball, punchball, great grey owl, great gray owl, Strix nebulosa, scale, weighing machine, trench coat, briard, cheetah, chetah, Acinonyx jubatus, entertainment center, Boston bull, Boston terrier, Arabian camel, dromedary, Camelus dromedarius, steam locomotive, coil, spiral, volute, whorl, helix, plane, carpenter's plane, woodworking plane, gondola, spider web, spider's web, bathtub, bathing tub, bath, tub, pelican, miniature poodle, cowboy boot, perfume, essence, lakeside, lakeshore, timber wolf, grey wolf, gray wolf, Canis lupus, moped, sunscreen, sunblock, sun blocker, Brabancon griffon, puffer, pufferfish, blowfish, globefish, lifeboat, pool table, billiard table, snooker table, Bouvier des Flandres, Bouviers des Flandres, Pomeranian, theater curtain, theatre curtain, marimba, xylophone, baboon, vacuum, vacuum cleaner, pill bottle, pick, plectrum, plectron, hen, American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier, digital watch, pier, oxygen mask, Tibetan terrier, chrysanthemum dog, ostrich, Struthio camelus, water ouzel, dipper, drilling platform, offshore rig, magnetic compass, throne, butternut squash, minibus, EntleBucher, carousel, carrousel, merry-go-round, roundabout, whirligig, hot pot, hotpot, rain barrel, wood rabbit, cottontail, cottontail rabbit, miniature pinscher, partridge, three-toed sloth, ai, Bradypus tridactylus, English springer, English springer spaniel, corkscrew, bottle screw, fur coat, robin, American robin, Turdus migratorius, dowitcher, ruddy turnstone, Arenaria interpres, water snake, stove, Great Pyrenees, soft-coated wheaten terrier, carbonara, snail, breastplate, aegis, egis, wolf spider, hunting spider, hatchet, CD player, axolotl, mud puppy, Ambystoma mexicanum, pomegranate, poncho, leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea, lorikeet, spatula, jay, platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus, stethoscope, flagpole, flagstaff, coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch, agama, red wolf, maned wolf, Canis rufus, Canis niger, beaker, eft, pretzel, brassiere, bra, bandeau, frilled lizard, Chlamydosaurus kingi, joystick, goldfish, Carassius auratus, fig, maypole, caldron, cauldron, admiral, impala, Aepyceros melampus, spotted salamander, Ambystoma maculatum, syringe, hog, pig, grunter, squealer, Sus scrofa, handkerchief, hankie, hanky, hankey, tarantula, cheeseburger, pinwheel, sax, saxophone, dung beetle, broccoli, cassette player, milk can, traffic light, traffic signal, stoplight, shovel, sarong, tabby, tabby cat, parallel bars, bars, ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle, quill, quill pen, giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca, steel drum, quail, Blenheim spaniel, wig, hamster, ice lolly, lolly, lollipop, popsicle, seashore, coast, seacoast, sea-coast, chest, worm fence, snake fence, snake-rail fence, Virginia fence, missile, beer bottle, yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum, breakwater, groin, groyne, mole, bulwark, seawall, jetty, white wolf, Arctic wolf, Canis lupus tundrarum, guacamole, porcupine, hedgehog, trolleybus, trolley coach, trackless trolley, greenhouse, nursery, glasshouse, trimaran, Italian greyhound, potter's wheel, jacamar, wallet, billfold, notecase, pocketbook, Lakeland terrier, green lizard, Lacerta viridis, indigo bunting, indigo finch, indigo bird, Passerina cyanea, green mamba, walking stick, walkingstick, stick insect, crossword puzzle, crossword, eggnog, barrow, garden cart, lawn cart, wheelbarrow, remote control, remote, bicycle-built-for-two, tandem bicycle, tandem, wool, woolen, woollen, black grouse, abaya, marmoset, golf ball, jeep, landrover, Mexican hairless, dishwasher, dish washer, dishwashing machine, jersey, T-shirt, tee shirt, planetarium, goose, mailbox, letter box, capuchin, ringtail, Cebus capucinus, marmot, orangutan, orang, orangutang, Pongo pygmaeus, coffeepot, ambulance, shopping basket, pop bottle, soda bottle, red fox, Vulpes vulpes, crash helmet, street sign, affenpinscher, monkey pinscher, monkey dog, Arctic fox, white fox, Alopex lagopus, sidewinder, horned rattlesnake, Crotalus cerastes, ruffed grouse, partridge, Bonasa umbellus, muzzle, measuring cup, canoe, reflex camera, fox squirrel, eastern fox squirrel, Sciurus niger, French loaf, killer whale, killer, orca, grampus, sea wolf, Orcinus orca, dial telephone, dial phone, thimble, bubble, vizsla, Hungarian pointer, running shoe, mailbag, postbag, radio telescope, radio reflector, piggy bank, penny bank, Chihuahua, chambered nautilus, pearly nautilus, nautilus, Airedale, Airedale terrier, kimono, green snake, grass snake, rubber eraser, rubber, pencil eraser, upright, upright piano, orange, revolver, six-gun, six-shooter, ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin, drum, membranophone, tympan, Dungeness crab, Cancer magister, lipstick, lip rouge, gong, tam-tam, fountain, tub, vat, malinois, sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita, German short-haired pointer, apron, Irish setter, red setter, dishrag, dishcloth, school bus, candle, taper, wax light, bib, cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM, power drill, English foxhound, miniskirt, mini, swing, slug, hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa, rifle, Saluki, gazelle hound, Sealyham terrier, Sealyham, bullet train, bullet, hyena, hyaena, ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus, toy terrier, goblet, safe, cup, electric guitar, red wine, restaurant, eating house, eating place, eatery, wall clock, washbasin, handbasin, washbowl, lavabo, wash-hand basin, red-breasted merganser, Mergus serrator, crate, banded gecko, hippopotamus, hippo, river horse, Hippopotamus amphibius, tick, tripod, sombrero, desk, sea slug, nudibranch, racer, race car, racing car, pizza, pizza pie, dining table, board, Saint Bernard, St Bernard, komondor, electric ray, crampfish, numbfish, torpedo, prairie chicken, prairie grouse, prairie fowl, coffee mug, hammer, golfcart, golf cart, unicycle, monocycle, bison, soup bowl, rapeseed, golden retriever, plastic bag, grey fox, gray fox, Urocyon cinereoargenteus, water tower, house finch, linnet, Carpodacus mexicanus, barbell, hair slide, tiger, Panthera tigris, black-footed ferret, ferret, Mustela nigripes, meat loaf, meatloaf, hand blower, blow dryer, blow drier, hair dryer, hair drier, overskirt, gibbon, Hylobates lar, Gila monster, Heloderma suspectum, toucan, snowmobile, pencil box, pencil case, scuba diver, cloak, Sussex spaniel, otter, Greater Swiss Mountain dog, great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias, torch, magpie, tiger shark, Galeocerdo cuvieri, wing, Border collie, bell cote, bell cot, sea anemone, anemone, teapot, sea urchin, screen, CRT screen, bookshop, bookstore, bookstall, oscilloscope, scope, cathode-ray oscilloscope, CRO, crib, cot, police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria, hartebeest, manhole cover, iPod, rock python, rock snake, Python sebae, nipple, suspension bridge, safety pin, sea lion, cougar, puma, catamount, mountain lion, painter, panther, Felis concolor, mantis, mantid, wardrobe, closet, press, projector, Granny Smith, diamondback, diamondback rattlesnake, Crotalus adamanteus, pirate, pirate ship, espresso maker, African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus, cradle, common newt, Triturus vulgaris, tricycle, trike, velocipede, bobsled, bobsleigh, bob, thunder snake, worm snake, Carphophis amoenus, thresher, thrasher, threshing machine, banjo, armadillo, pajama, pyjama, pj's, jammies, ski, Maltese dog, Maltese terrier, Maltese, leafhopper, book jacket, dust cover, dust jacket, dust wrapper, silky terrier, Sydney silky, Shih-Tzu, wallaby, brush kangaroo, cardigan, sturgeon, freight car, home theater, home theatre, sundial, African crocodile, Nile crocodile, Crocodylus niloticus, odometer, hodometer, mileometer, milometer, sliding door, vine snake, West Highland white terrier, mongoose, hornbill, beagle, European gallinule, Porphyrio porphyrio, submarine, pigboat, sub, U-boat, Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis, cock, pedestal, plinth, footstall, accordion, piano accordion, squeeze box, gown, lynx, catamount, guenon, guenon monkey, Walker hound, Walker foxhound, standard schnauzer, reel, hip, rose hip, rosehip, grasshopper, hopper, Dutch oven, stone wall, hard disc, hard disk, fixed disk, snow leopard, ounce, Panthera uncia, shopping cart, digital clock, hourglass, Border terrier, Old English sheepdog, bobtail, academic gown, academic robe, judge's robe, spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish, spotlight, spot, dome, barn spider, Araneus cavaticus, bee eater, basketball, cliff dwelling, folding chair, isopod, Doberman, Doberman pinscher, bittern, sunglasses, dark glasses, shades, picket fence, paling, Crock Pot, ibex, Capra ibex, neck brace, cardoon, cassette, amphibian, amphibious vehicle, minivan, analog clock, trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi, yurt, cliff, drop, drop-off, Bernese mountain dog, teddy, teddy bear, sloth bear, Melursus ursinus, Ursus ursinus, bassoon, toaster, ptarmigan, Gordon setter, night snake, Hypsiglena torquata, grand piano, grand, purse, clumber, clumber spaniel, shoji, hair spray, maillot, knee pad, space heater, bottlecap, chiffonier, commode, chain saw, chainsaw, sulphur butterfly, sulfur butterfly, pay-phone, pay-station, kelpie, mouse, computer mouse, car wheel, cornet, horn, trumpet, trump, container ship, containership, container vessel, matchstick, scabbard, American black bear, black bear, Ursus americanus, Euarctos americanus, langur, rock crab, Cancer irroratus, lionfish, speedboat, black stork, Ciconia nigra, knot, disk brake, disc brake, mosquito net, white stork, Ciconia ciconia, abacus, titi, titi monkey, grocery store, grocery, food market, market, waffle iron, pickelhaube, wooden spoon, Norwegian elkhound, elkhound, earthstar, sewing machine, balance beam, beam, potpie, chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour, Staffordshire bullterrier, Staffordshire bull terrier, switch, electric switch, electrical switch, dhole, Cuon alpinus, paddle, boat paddle, limousine, limo, Shetland sheepdog, Shetland sheep dog, Shetland, space bar, library, paddlewheel, paddle wheel, alligator lizard, Band Aid, Persian cat, bull mastiff, tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui, sports car, sport car, football helmet, laptop, laptop computer, lens cap, lens cover, tennis ball, violin, fiddle, lab coat, laboratory coat, cinema, movie theater, movie theatre, movie house, picture palace, weasel, bow tie, bow-tie, bowtie, macaw, dough, whiskey jug, microphone, mike, spoonbill, bassinet, mud turtle, velvet, warthog, plunger, plumber's helper, dugong, Dugong dugon, honeycomb, badger, dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk, bee, doormat, welcome mat, fountain pen, giant schnauzer, assault rifle, assault gun, limpkin, Aramus pictus, siamang, Hylobates syndactylus, Symphalangus syndactylus, albatross, mollymawk, confectionery, confectionary, candy store, harp, parachute, chute, barrel, cask, tank, army tank, armored combat vehicle, armoured combat vehicle, collie, kite, puck, hockey puck, stupa, tope, buckeye, horse chestnut, conker, patio, terrace, broom, Dandie Dinmont, Dandie Dinmont terrier, scorpion, agaric, balloon, bucket, pail, squirrel monkey, Saimiri sciureus, Eskimo dog, husky, zebra, garter snake, grass snake, indri, indris, Indri indri, Indri brevicaudatus, tractor, guinea pig, Cavia cobaya, maraca, red-backed sandpiper, dunlin, Erolia alpina, bullfrog, Rana catesbeiana, trilobite, Japanese spaniel, gorilla, Gorilla gorilla, monastery, centipede, terrapin, llama, long-horned beetle, longicorn, longicorn beetle, boxer, curly-coated retriever, mortar, hammerhead, hammerhead shark, goldfinch, Carduelis carduelis, garden spider, Aranea diademata, stopwatch, stop watch, grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus, leaf beetle, chrysomelid, birdhouse, king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica, stole, bell pepper, radiator, flatworm, platyhelminth, mushroom, Scotch terrier, Scottish terrier, Scottie, liner, ocean liner, toilet seat, lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens, zucchini, courgette, harvestman, daddy longlegs, Phalangium opilio, Newfoundland, Newfoundland dog, flamingo, whiptail, whiptail lizard, geyser, cleaver, meat cleaver, chopper, sea cucumber, holothurian, American egret, great white heron, Egretta albus, parking meter, beacon, lighthouse, beacon light, pharos, coucal, motor scooter, scooter, mitten, cannon, weevil, megalith, megalithic structure, stinkhorn, carrion fungus, ear, spike, capitulum, box turtle, box tortoise, snowplow, snowplough, tench, Tinca tinca, modem, tobacco shop, tobacconist shop, tobacconist, barn, skunk, polecat, wood pussy, African grey, African gray, Psittacus erithacus, Madagascar cat, ring-tailed lemur, Lemur catta, holster, barometer, sleeping bag, washer, automatic washer, washing machine, recreational vehicle, RV, R.V., drake, tray, butcher shop, meat market, china cabinet, china closet, medicine chest, medicine cabinet, photocopier, Yorkshire terrier, starfish, sea star, racket, racquet, park bench, Labrador retriever, whistle, clog, geta, patten, sabot, volcano, quilt, comforter, comfort, puff, leopard, Panthera pardus, cauliflower, swimming trunks, bathing trunks, American chameleon, anole, Anolis carolinensis, alp, mortarboard, barracouta, snoek, cocker spaniel, English cocker spaniel, cocker, space shuttle, beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon, harmonica, mouth organ, harp, mouth harp, gasmask, respirator, gas helmet, wombat, Model T, wild boar, boar, Sus scrofa, hermit crab, flat-coated retriever, rotisserie, jinrikisha, ricksha, rickshaw, trifle, bannister, banister, balustrade, balusters, handrail, go-kart, bakery, bakeshop, bakehouse, ski mask, dock, dockage, docking facility, Egyptian cat, oxcart, redbone, shoe shop, shoe-shop, shoe store, convertible, ox, crayfish, crawfish, crawdad, crawdaddy, cowboy hat, ten-gallon hat, conch, spaghetti squash, toy poodle, saltshaker, salt shaker, microwave, microwave oven, triceratops, necklace, castle, streetcar, tram, tramcar, trolley, trolley car, eel, diaper, nappy, napkin, standard poodle, prayer rug, prayer mat, radio, wireless, crane, envelope, rule, ruler, gar, garfish, garpike, billfish, Lepisosteus osseus, spider monkey, Ateles geoffroyi, Irish wolfhound, German shepherd, German shepherd dog, German police dog, alsatian, umbrella, sunglass, aircraft carrier, carrier, flattop, attack aircraft carrier, water buffalo, water ox, Asiatic buffalo, Bubalus bubalis, jellyfish, groom, bridegroom, tree frog, tree-frog, steel arch bridge, lemon, pickup, pickup truck, vault, groenendael, baseball, junco, snowbird, maillot, tank suit, gazelle, jack-o'-lantern, military uniform, slide rule, slipstick, wire-haired fox terrier, acorn squash, electric fan, blower, Brittany spaniel, chimpanzee, chimp, Pan troglodytes, pillow, binder, ring-binder, schipperke, Afghan hound, Afghan, plate rack, car mirror, hand-held computer, hand-held microcomputer, papillon, schooner, Bedlington terrier, cellular telephone, cellular phone, cellphone, cell, mobile phone, altar, Chesapeake Bay retriever, cabbage butterfly, polecat, fitch, foulmart, foumart, Mustela putorius, comic book, French horn, horn, daisy, organ, pipe organ, mashed potato, acorn, fly, chain, American alligator, Alligator mississipiensis, mink, garbage truck, dustcart, totem pole, wine bottle, strawberry, cricket, European fire salamander, Salamandra salamandra, coral reef, Welsh springer spaniel, bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis, snorkel, bald eagle, American eagle, Haliaeetus leucocephalus, meerkat, mierkat, grille, radiator grille, nematode, nematode worm, roundworm, anemone fish, corn, loggerhead, loggerhead turtle, Caretta caretta, palace, suit, suit of clothes, pineapple, ananas, macaque, ping-pong ball, ram, tup, church, church building, koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus, hare, bath towel, strainer, yawl, otterhound, otter hound, table lamp, king snake, kingsnake, lotion, lion, king of beasts, Panthera leo, thatch, thatched roof, basset, basset hound, black and gold garden spider, Argiope aurantia, barber chair, proboscis monkey, Nasalis larvatus, consomme, Irish terrier, Irish water spaniel, common iguana, iguana, Iguana iguana, Weimaraner, Great Dane, pug, pug-dog, rhinoceros beetle, vase, brass, memorial tablet, plaque, kit fox, Vulpes macrotis, king penguin, Aptenodytes patagonica, vending machine, dalmatian, coach dog, carriage dog, rock beauty, Holocanthus tricolor, pole, cuirass, bolete, jackfruit, jak, jack, monarch, monarch butterfly, milkweed butterfly, Danaus plexippus, chow, chow chow, nail, packet, half track, Lhasa, Lhasa apso, boathouse, hay, valley, vale, slot, one-armed bandit, volleyball, carton, shower cap, tile roof, lacewing, lacewing fly, patas, hussar monkey, Erythrocebus patas, boa constrictor, Constrictor constrictor, black swan, Cygnus atratus, lampshade, lamp shade, mousetrap, crutch, vestment, Pekinese, Pekingese, Peke, tusker, warplane, military plane, sandal, screw, custard apple, Scottish deerhound, deerhound, spindle, keeshond, hummingbird, letter opener, paper knife, paperknife, cucumber, cuke, bearskin, busby, shako, fire engine, fire truck, trombone, ringneck snake, ring-necked snake, ring snake, sorrel, fire screen, fireguard, paper towel, flute, transverse flute, hotdog, hot dog, red hot, Indian elephant, Elephas maximus, mosque, stingray, Rhodesian ridgeback, four-poster +

+
+ """, 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 ViT classifier +imageClassifier = ViTForImageClassification \\ + .pretrained("image_classifier_vit_base_patch16_224") \\ + .setInputCols(["image_assembler"]) \\ + .setOutputCol("label") + +# 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", "label.result") \\ + .show(truncate=False) +''', language='python') + +# Results +st.markdown('
Results
', unsafe_allow_html=True) +st.markdown(""" +
+ + + + + + + + + + + + + + + + + +
Image NameResult
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(""" +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
Model Nameimage_classifier_vit_base_patch16_224
CompatibilitySpark NLP 5.2.0+
LicenseOpen Source
EditionOfficial
Input Labels[image_assembler]
Output Labels[classification]
Languageen
Size334.8 MB
+
+""", unsafe_allow_html=True) + +# Predicted Entities +st.markdown('
Predicted Entities
', unsafe_allow_html=True) +st.markdown(""" +
+ +
+""", unsafe_allow_html=True) + +# Data Source Section +st.markdown('
Data Source
', unsafe_allow_html=True) +st.markdown(""" +
+

The ViT model is available on Hugging Face. This model was trained on a large dataset of images and can be used for accurate image classification.

+
+""", 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) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3d47d93d88a67d9603034823b99d5f448dca36b0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +streamlit +streamlit-tags +pandas +numpy +spark-nlp +pyspark \ No newline at end of file