馃悰 Bug
After running pip install 'lightning-flash[image]', when I try to create an ImageEmbedder, I get:
ModuleNotFoundError: Required dependencies not available. Please run: pip install 'lightning-flash[image]'
Background:
- I am trying to create an image embedding model.
- I want to follow the embeddings tutorial to get started.
- I want to run the tutorial interactively in a notebook so I can play with it easily.
- I have installed
lightning-flash[image] into a docker container built on the jupyter base-notebook container, to minimise what else is installed.
- Using python 3.9 because I see
lightning-flash is tagged as supporting python 3.7, 3.8, 3.9.
To Reproduce
1. Create this Dockerfile:
FROM jupyter/base-notebook:python-3.9
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
RUN pip install 'lightning-flash[image]'
EXPOSE 8888
2. Build the container and save the build logs
docker build --no-cache --progress=plain -t flash:latest . &> build.log
Build log file is attached, looks fine to me.
build.log
3. Run the container and create a notebook
I run as root, and mount the notebooks folder to save my work: docker run -it -v $(PWD)/notebooks:/home/jovyan/work --user root -e GRANT_SUDO=yes -p 8888:8888 flash:latest
Navigate to http://127.0.0.1:8888/lab/tree/work/ in the browser and enter the token. Create a notebook.
4. Run the following code from the embeddings tutorial:
import torch
from torchvision.datasets import CIFAR10
import flash
from flash.core.data.utils import download_data
from flash.image import ImageClassificationData, ImageEmbedder
# # 1. Download the data and prepare the datamodule
# datamodule = ImageClassificationData.from_datasets(
# train_dataset=CIFAR10("./cifar10", download=True),
# batch_size=8,
# )
# 2. Build the task
embedder = ImageEmbedder(
backbone="resnet18",
training_strategy="barlow_twins",
head="barlow_twins_head",
pretraining_transform="barlow_twins_transform",
training_strategy_kwargs={"latent_embedding_dim": 128},
pretraining_transform_kwargs={"size_crops": [32]},
)
This produces the following error:
/opt/conda/lib/python3.9/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
/opt/conda/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension:
warn(f"Failed to load image Python extension: {e}")
/opt/conda/lib/python3.9/site-packages/torchvision/models/_utils.py:252: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and may be removed in the future. Please access them via the appropriate Weights Enum instead.
warnings.warn(
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In [3], line 16
6 from flash.image import ImageClassificationData, ImageEmbedder
8 # # 1. Download the data and prepare the datamodule
9 # datamodule = ImageClassificationData.from_datasets(
10 # train_dataset=CIFAR10("./cifar10", download=True),
(...)
14
15 # 2. Build the task
---> 16 embedder = ImageEmbedder(
17 backbone="resnet18",
18 training_strategy="barlow_twins",
19 head="barlow_twins_head",
20 pretraining_transform="barlow_twins_transform",
21 training_strategy_kwargs={"latent_embedding_dim": 128},
22 pretraining_transform_kwargs={"size_crops": [32]},
23 )
File /opt/conda/lib/python3.9/site-packages/flash/core/utilities/imports.py:164, in requires.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
162 @functools.wraps(func)
163 def wrapper(*args, **kwargs):
--> 164 raise ModuleNotFoundError(
165 f"Required dependencies not available. Please run: pip install {' '.join(modules)}"
166 )
ModuleNotFoundError: Required dependencies not available. Please run: pip install 'lightning-flash[image]'
Expected behavior
After installing lightning-flash[image] I should not get an error message telling me to install lightning-flash[image]. I should be able to instantiate an ImageEmbedder.
Environment
- OS (e.g., Linux): linux/arm64/v8
- Python version: 3.9.13
- PyTorch/Lightning/Flash Version (e.g., 1.10/1.5/0.7):
- Torch: 1.13.1
- Flash: 0.8.1.post0
- GPU models and configuration: N/A (cpu)
- Any other relevant information: see above
馃悰 Bug
After running
pip install 'lightning-flash[image]', when I try to create anImageEmbedder, I get:ModuleNotFoundError: Required dependencies not available. Please run: pip install 'lightning-flash[image]'Background:
lightning-flash[image]into a docker container built on the jupyter base-notebook container, to minimise what else is installed.lightning-flashis tagged as supporting python 3.7, 3.8, 3.9.To Reproduce
1. Create this Dockerfile:
2. Build the container and save the build logs
docker build --no-cache --progress=plain -t flash:latest . &> build.logBuild log file is attached, looks fine to me.
build.log
3. Run the container and create a notebook
I run as root, and mount the notebooks folder to save my work:
docker run -it -v $(PWD)/notebooks:/home/jovyan/work --user root -e GRANT_SUDO=yes -p 8888:8888 flash:latestNavigate to http://127.0.0.1:8888/lab/tree/work/ in the browser and enter the token. Create a notebook.
4. Run the following code from the embeddings tutorial:
This produces the following error:
Expected behavior
After installing
lightning-flash[image]I should not get an error message telling me to installlightning-flash[image]. I should be able to instantiate anImageEmbedder.Environment