
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.