American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – AI and Machine Learning – Gamas

October 8 @ 7:00 pm - 8:00 pm

Today We Did
  1. We added fast.ai library in our pycharm
  2. It seems like fast.ai library only works in Python <= 3.12.
  3. We were able to utilize cat_vs_dog_model.pkl file into our Pycharm project.
  4. We were able to have our streamlit web application to predict cat or dog images.
Homework
  1. In your pycharm. Change code from
  2. uploaded_file = st.file_uploader("Choose as image...", type=["jpg", "png", "jpeg"])
    if uploaded_file is not None:
        fastai_img = PILImage.create(uploaded_file)
        prediction = cat_vs_dog_model.predict(fastai_img)
    
        img_label = None
        if prediction[0] == 'True':
            img_label = f"CAT"
        else:
            img_label = f"DOG"
        st.text(img_label)
        st.image(uploaded_file, caption="Uploaded Image", use_container_width=True)

    Into

    uploaded_file = st.file_uploader("Choose as image...", type=["jpg", "png", "jpeg"])
    if uploaded_file is not None:
        fastai_img = PILImage.create(uploaded_file)
        prediction = cat_vs_dog_model.predict(fastai_img)
    
        img_label = None
        if prediction[0] == 'True':
            img_label = f"CAT - {prediction[2][0]}"
        else:
            img_label = f"DOG - {prediction[2][1]}"
        st.text(img_label)
        st.image(uploaded_file, caption="Uploaded Image", use_container_width=True)

    After that rerun your streamlit and upload cat or dog image and see what is the difference now? And figure out what kind of information prediction[2][0] or prediction[2][1] reveals. Try researching the Internet or ask chatGPT below question

    “””

    I am using fast.ai library to create a custom model. When I used the custom model to do prediction, what kind of information the 3rd element in the prediction result provided.

    fastai_img = PILImage.create(uploaded_file)
    prediction = cat_vs_dog_model.predict(fastai_img)

    “””

    Study answer by ChatGPT because I am going to ask you this next week.

Details

Date:
October 8
Time:
7:00 pm - 8:00 pm