I am using a file_uploader from streamlit to get images into PIL JpegImageFile format :
import streamlit as st
inferencer = load_learner(path)
img_bytes = st.file_uploader("Squash It!!", type=['png', 'jpg', 'jpeg'])
if img_bytes is not None:
st.write("Image Uploaded Successfully:")
img = PIL.Image.open(img_bytes)
pred_class, pred_idx, outputs = inferencer.predict(img)
for out in outputs:
st.write(out)
st.write("Decision: ", pred_class)
However, I can’t find a method in the docs that will convert a PIL Image to a fastai Image. It seems without having that fastai wrapper, I can’t do inference. I get the error:
'JpegImageFile' object has no attribute 'apply_tfms'
File "C:\Users\WNeill\PycharmProjects\fastai-homework\Lesson2-v3\inference.py", line 20, in <module>
pred_class, pred_idx, outputs = inferencer.predict(img)
Hi @arora_aman, I do not see that method in the docs for fastai… Can you point me to the documentation?
Edit: I think what you are referring to is part of the new library. I am going through the v3 course and have no desire to try implementing fastai2. I tried it once, and will not again.
fastai2 has changed the mid level and low level APIs dramatically, if you’re not comfortable yet, go through the v3 course once and then refer these fastai2 course notebooks to understand what has been changed.
I urge you to learn more about fastai2 because it’s damm good
Hi, I am also working on related issues, I want to convert a tensor to a fastAI image, I want to call the Image() but it said the ‘module’ object is not callable. Is the Image has been removed from the fastai? How do I convert the image tensor to a fastai image object. Thank you.
hello sir, im working on a segmentation problem,
i need to convert the “img.show(y=model_inf.predict(img)[0], figsize=(10,10))” output to a pillow image, how do i do that?