drivendataorg / zamba

A Python package for identifying 42 kinds of animals, training custom models, and estimating distance from camera trap videos
https://zamba.drivendata.org/docs/stable/
MIT License
116 stars 27 forks source link

Native Windows installation and execution instructions #300

Open pjbull opened 1 year ago

pjbull commented 1 year ago

Currently, we recommend Docker desktop or WSL for Windows.

It should be possible to run natively if yolox at our version pin can be compiled.

PR #222 had some initial work on this, but it was not generalizable to all Windows systems.

lakik commented 1 year ago

This was the procedure that finally lead me to success:

.# WSL INSTALL ON WINDOWS 11 .# open powershell and install latest Ubuntu version wsl --install

restart Windows open Ubuntu

-------------------------------------------------------------------------------

.# UBUNTU UPDATE sudo apt update && sudo apt upgrade

sudo apt-get install build-essential sudo apt install ffmpeg

sudo apt update && sudo apt upgrade

-------------------------------------------------------------------------------

.# PYTHON 3.9

sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.9 sudo apt-get install python3.9-dev

.# check what is the default version python3 --version

.# check installed versions sudo ls /usr/bin/python* .# make 3.9 as default sudo ln -sf /usr/bin/python3.9 /usr/bin/python3 .# check python3 --version

.# install missing package sudo apt install python3.9-distutils

-------------------------------------------------------------------------------------------------------------------------

.# ZAMBA pip install https://github.com/drivendataorg/zamba/releases/latest/download/zamba.tar.gz

.# check success pip show zamba

-------------------------------------------------------------------------------------------------------------------------

lywusa commented 1 year ago

With WSL, I was able to run Zamba in the CLI, but how can I run it as a Python package? Not sure even after reading all tutorials. I have VS code.

pjbull commented 12 months ago

From the documentation, you can see the basic example of using as a Python package. I copy that here:

from zamba.models.model_manager import predict_model
from zamba.models.config import PredictConfig

predict_config = PredictConfig(data_dir="example_vids/")
predict_model(predict_config=predict_config)

As linked from that documentation, the same things that you can pass to the CLI, you can pass into the PredictConfig. Those possible options are documented here. You can also override the default options for how videos get loaded (which is advanced functionality), using the VideoLoaderConfig.

So, for example, if I wanted to predict on a different directory called my_vids/ and change some of the prediction settings, I could do something like:

from zamba.models.model_manager import predict_model
from zamba.models.config import PredictConfig

predict_config = PredictConfig(
    data_dir="my_vids/",
    save_dir="zamba_output/",     # save to different directory
    model_name="european",        # run the model with European species
    weight_download_region="eu",  # download the model from the EU data center
)

predict_model(predict_config=predict_config)

If you save that script as my_script.py running it is as easy as running python my_script.py, assuming you have Python installed.

lywusa commented 11 months ago

Thanks for your reply. I have Windows 11+WSL/VS Code and have to put everything under if __name__ == '__main_\': to run correctly .