Closed 2320sharon closed 1 year ago
Dan is working on finishing the Gym update first, then make all the zenodo releases, then next week we can add the dependency and test
Here is the latest progress on finding a conda recipe that works with the coastseg environment.
A common issue I've discovered is that the transformers library messes with the way the fiona library loads which means that geopandas can't load geojson files. I hypothesize this is due to the h5py
library because when the h5py
is uninstalled and reinstalled with conda forge everything works correctly.
conda create -n coastseg_transformers2 python=3.10 -y
conda activate coastseg_transformers2
pip install tensorflow
conda install -c conda-forge transformers==4.29.2
pip install chardet
conda install -c conda-forge geopandas -y
conda install -c conda-forge jupyterlab -y
pip install coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
I'm testing on this environment on a windows 11 machine
I was able to get this recipe to work on a windows 11 machine.
I noticed that it took a very long time to resolve conflicting dependencies at the conda install -c conda-forge geopandas -y
step.
When I ran the notebook with the unet models it took about 4 times longer than normal to load in coastseg with the transformers.
[x] Experiment with simpler recipes for installing transformers
[x] Figure out why its slow to import
[x] Try with one of the new segformer models to figure out it works
[ ] post the updated recipe to the readme
Here is my latest recipe that worked. I'm going to be trying this out with the new models in #152
conda create -n coastseg_transformers7 python=3.10 -y
conda activate coastseg_transformers7
conda install -c conda-forge transformers==4.29.2
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow chardet coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
I was able to get the segformer_RGB_4class_7933015 to run in this environment
Dan was able to get this recipe to work on miniconda
conda create -n coastseg_transformers7 python=3.10 -y
conda activate coastseg_transformers7
conda install -c conda-forge transformers==4.29.2
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow chardet coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
pip uninstall transformers
pip install seg2map
We need to figure out what package is installing transformers from pip which is overriding the transformers we installed from conda
Dan is in the process of trying this recipe to simply the conda recipe
conda create -n coastseg_transformers8 python=3.10 -y
conda activate coastseg_transformers8
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow chardet coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
pip uninstall transformers
pip install seg2map
I have confirmed that the tensorflow from pip does not install the transformers library
I got this far
conda create -n coastseg_transformers8 python=3.10 -y
conda activate coastseg_transformers8
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow chardet coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
then decided to test at this point to see what was installed. TF is installed: python -c "import tensorflow as tf"
but transformers is not installed (python -c "import transformers"
), so I confirm the observation that TF does not install transformers
At this point, I do not need the line pip uninstall transformers
Completing the installation with pip install seg2map
, I can now test the transformers library with python -c "from transformers import TFSegformerForSemanticSegmentation"
. Success!!!
conda create -n coastseg_transformers8 python=3.10 -y
conda activate coastseg_transformers8
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow chardet coastseg
pip uninstall h5py
conda install -c conda-forge h5py -y
pip install seg2map
its dumb, but works. my only nervousness was that by installing seg2map after coastseg, we somehow messed up the coastseg functions, but a quick runthrough of the coastseg notebooks made me think that everything was ok. I was able to download images and extract shorelines using the coastsat classifier notebook, at least. and the unet notebook rendered ok, but I didnt test the model
Thank you for trying this out. This makes me think that we can add transformers as a dependency to coastseg in the pyproject.toml file because transformers doesn't automatically install tensorflow.
Here is what I'm going to try
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project] name = "coastseg" dynamic = ["readme"] version = "0.0.70" authors = [ { name=" Sharon Fitzpatrick", email="sharon.fitzpatrick23@gmail.com" }, ]
directive with
includeor
exclude`description = "An interactive jupyter notebook for downloading satellite imagery" dependencies = [ "coastsat-package>=0.1.13", "area", "doodleverse-utils>=0.0.29", "ipyfilechooser>=0.6.0", "tqdm", "leafmap>=0.14.0", "geojson", "aiohttp", "nest-asyncio", "tensorflow", "dask", "ipywidgets>=8.0.6", "transformers", "chardet" ]
license = { file="LICENSE" } requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", "Topic :: Scientific/Engineering :: GIS", ]
[tool.setuptools.packages.find] where = ["src"]
[project.urls] "Homepage" = "https://github.com/SatelliteShorelines/CoastSeg" "Bug Tracker" = "https://github.com/SatelliteShorelines/CoastSeg/issues"
2. Try out this conda recipe
conda create -n coastseg_transformers9 python=3.10 -y conda activate coastseg_transformers9 conda install -c conda-forge geopandas jupyterlab -y pip install coastseg tensorflow pip uninstall h5py conda install -c conda-forge h5py -y
edit: I messed up and didn't run pip install -e .
so after I installed this recipe I ran the following
cd coastseg pip install -e .
3. Try running
`from transformers import TFSegformerForSemanticSegmentation`
4. This worked!!
I've got some great news! I was able to apply the segformer model segformer_RGB_4class_7933015
to the imagery in this environment!
It's pretty fast too!
I'm going to double check then make these changes official
I tried this conda recipe on the add_new_segformer_model branch and it worked.
I already modified the pyproject.toml file so all you should need to do is
git fetch
git switch add_new_segformer_model
conda create -n coastseg_transformers9 python=3.10 -y
conda activate coastseg_transformers9
conda install -c conda-forge geopandas jupyterlab -y
pip install tensorflow
cd coastseg
pip install -e .
pip uninstall h5py
conda install -c conda-forge h5py -y
Then select the segformer model from under the RGB section
The new segformer model has been added and the installation instructions have been finalized. These changes are active in coastseg==0.0.72.dev6
The doodleverse will be changing to accomodate the new .keras model format, and a new set of Transformer models will soon be published to Zenodo. To use these new models tensorflow 2.12 and transformers need to be installed .
A
conda install -c conda-forge transformers
in this new coastseg env should work to add the transformers package.