Comments (6)
Ok. I downgraded to pillow 9.5.0 and now it works.
from fastbook.
I have the same problem. The problem is that im.mode='RGBA' which throws a KeyError in JpegImagePlugin.py:
KeyError Traceback (most recent call last)
File ~/mambaforge/lib/python3.10/site-packages/PIL/JpegImagePlugin.py:639, in _save(im, fp, filename)
638 try:
--> 639 rawmode = RAWMODE[im.mode]
640 except KeyError as e:
KeyError: 'RGBA'
I tried converting the images to RGB and re-saving them, but no luck, so I'm guessing fastai converts them to RGBA somewhere along the way?
fns = get_image_files(path)
for fn in fns:
im = Image.open(fn)
im = im.convert('RGB')
im.save(fn)
from fastbook.
@couzhei @ed-kung I have this issue too. Did either of you guys figure out a solution?
from fastbook.
I actually dropped this investigation a while ago since I found out @jph00 is onto preparing the second edition of the book while the recent course of fastai didn't cover the type of production fastai API intended (@jph00 changed the focus quite rightfully into another tool called Gradio, which I believe is the new hype around the community, also great advertising came from both deeplearning.ai and Huggingface communities), but out of curiosity about @ed-kung's investigations I ran through it and it is apparently fine now! I don't know what made this happen but I list possible options that might be suspicious, so i t might not be an actual solution, I guess from fastbook import *
might make the python management system confused that all the dependencies are provided or don't upgrade your existing packages, or it might relate to the version of your notebook (I downgraded it), also I seemed to have newer version of lxml
, httpcore
, and httpx
compared to the previous environment.
from fastbook.
Strange. I have the current latest versions of every package so no clue what might be causing it! And yes, I'm using Gradio as well.
from fastbook.
I tried converting the images to RGB and re-saving them, but no luck, so I'm guessing fastai converts them to RGBA somewhere along the way?
The open_thumb function of this widget converts to RBGA. I deleted the .convert('RGBA') part of the code below and the widget no longer throws a KeyError. Seems to work, but I have no idea whether that's needed for something else.
def _open_thumb(
fn:Path|str, # A path of an image
h:int, # Thumbnail Height
w:int # Thumbnail Width
) -> Image: # `PIL` image to display
"Opens an image path and returns the thumbnail of the image"
return Image.open(fn).to_thumb(h, w).convert('RGBA')
The rest of the code is here: https://github.com/fastai/fastai/blob/master/fastai/vision/widgets.py
from fastbook.
Related Issues (20)
- Bing Image Search - API issue HOT 1
- Error in the The operator 'aten::_linalg_solve_ex.result' in the aug_transforms function in the Data Augmentation HOT 1
- 09_tabular: ProductSize histogram's y-axis is mislabeled HOT 2
- Notebook files are not loaded.
- `n_workers` has to be changed to 0 to avoid getting stuck
- Import treeinterpreter and waterfall_charts before plotting #chap_09
- Link to "A Mathematician's Lament" short story is broken
- Unable to download images in Chapter 2 Production HOT 1
- Chapter 6: TypeError in Binary Cross Entropy calculation using both nn.BCEWithLogitsLoss() and F.binary_cross_entropy_with_logits() HOT 1
- Windows 10/11 Setup Guide without Docker, WSL, Ubuntu, or Cloud Hosting HOT 2
- Outdated sklearn.inspection.plot_partial_dependence HOT 1
- Cannot add in loss function when creating learner
- Honest impression on 04_mnist_basics
- general variable naming
- ZH translation of this book
- Python 3.12 incompatibilites with fastbook
- Typo: `relfects` -> `reflects`
- Small correction to 06_multicat
- Chapter 2 and Cloud Services HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastbook.