cog
cog copied to clipboard
Incompatibility with pydantic
Hello, I know engineers in @replicate work with this issue in Pull requests. But want to know how I can push the image with uninstalling and installing new version of packages in cog.yaml, too
Thank you!
Validating model schema...
Traceback (most recent call last):
File "/root/.pyenv/versions/3.10.14/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/root/.pyenv/versions/3.10.14/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/cog/command/openapi_schema.py", line 25, in <module>
raise CogError(app.state.setup_result.logs)
cog.errors.CogError: Error while loading predictor:
Traceback (most recent call last):
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/cog/server/http.py", line 137, in create_app
predictor = load_predictor_from_ref(predictor_ref)
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/cog/predictor.py", line 187, in load_predictor_from_ref
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/src/predict.py", line 10, in <module>
from insightface.app import FaceAnalysis
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/insightface/__init__.py", line 18, in <module>
from . import app
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/insightface/app/__init__.py", line 2, in <module>
from .mask_renderer import *
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/insightface/app/mask_renderer.py", line 4, in <module>
import albumentations as A
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/__init__.py", line 3, in <module>
from .augmentations import *
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/augmentations/__init__.py", line 1, in <module>
from .blur.functional import *
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/augmentations/blur/__init__.py", line 1, in <module>
from .functional import *
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/augmentations/blur/functional.py", line 9, in <module>
from albumentations.augmentations.geometric.functional import scale
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/augmentations/geometric/__init__.py", line 2, in <module>
from .resize import *
File "/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/albumentations/augmentations/geometric/resize.py", line 6, in <module>
from pydantic import Field, ValidationInfo, field_validator
ImportError: cannot import name 'ValidationInfo' from 'pydantic' (/root/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pydantic/__init__.cpython-310-x86_64-linux-gnu.so)
I have the same issue, fighting against it 12 hours already
@jyoung105 found the problem it is actually because of algumentations : specify the version 1.4.3, two days ago they release 1.4.4 and it breaks everything
https://github.com/albumentations-team/albumentations/pull/1624
Thanks @cryptexis @fofr
After arriving at office, I will take a look. I didn't check albumentation, just pydantic and insightface.
Thanks once again 😀
@jyoung105 After dealing with this issue I found out that in my case it was due to a dependency mismatch , instant id is currently compatible with this library with this version : albumentations==1.4.3
and if you check albumentations is not pinned in the yaml file therefore newest version (1.4.4) would be installed and raises a pydantic error , My yaml file looks like this and it works:
build:
# set to true if your model requires a GPU
gpu: true
# cuda: "12.1"
# a list of ubuntu apt packages to install
system_packages:
- "libgl1-mesa-glx"
- "libglib2.0-0"
# python version in the form '3.11' or '3.11.4'
python_version: "3.11"
# a list of packages in the format <package-name>==<version>
python_packages:
- "albumentations==1.4.3"
- "opencv-python==4.9.0.80"
- "transformers==4.37.0"
- "accelerate==0.26.1"
- "insightface==0.7.3"
- "diffusers==0.25.1"
- "onnxruntime==1.16.3"
- "omegaconf==2.3.0"
- "pandas==2.0.3"
# commands run after the environment is setup
run:
- curl -o /usr/local/bin/pget -L "https://github.com/replicate/pget/releases/download/v0.6.0/pget_linux_x86_64" && chmod +x /usr/local/bin/pget
- pip freeze
# predict.py defines how predictions are run on your model
predict: "cog/predict.py:Predictor"
Hope that it fixes your case as well 😊