ImageLoader¶
Component that can turn filepaths into a list of PIL.Image objects.
Parameters
Name | Type | Description | Default |
---|---|---|---|
convert |
str |
Color conversion setting from the Python image library. | 'RGB' |
out |
str |
What kind of image output format to expect. | 'pil' |
Usage
You can use the ImageLoader
in standalone fashion.
from embetter.vision import ImageLoader
filepath = "tests/data/thiscatdoesnotexist.jpeg"
ImageLoader(convert="RGB").fit_transform([filepath])
But it's more common to see it part of a pipeline.
import pandas as pd
from sklearn.pipeline import make_pipeline
from embetter.grab import ColumnGrabber
from embetter.vision import ImageLoader, ColorHistogramEncoder
# Let's say we start we start with a csv file with filepaths
data = {"filepaths": ["tests/data/thiscatdoesnotexist.jpeg"]}
df = pd.DataFrame(data)
# Let's build a pipeline that grabs the column, turns it
# into an image and embeds it.
pipe = make_pipeline(
ColumnGrabber("filepaths"),
ImageLoader(),
ColorHistogramEncoder()
)
pipe.fit_transform(df)
fit(self, X, y=None)
¶
Show source code in vision/_loader.py
56 57 58 59 60 61 62 63 64 65 |
|
Not actual "fitting" happens in this method, but it does check the input arguments per sklearn convention.
transform(self, X, y=None)
¶
Show source code in vision/_loader.py
67 68 69 70 71 72 73 74 |
|
Turn a file path into numpy array containing pixel values.