# upgrade python
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install -y libgl1
sudo apt install python3.12 -y
sudo apt install python3.12-venv -y


# link python to python3.12
sudo ln /usr/bin/python3.12 /usr/bin/python

# install pip
wget https://bootstrap.pypa.io/get-pip.py | python get-pip.py


# virtual venv
python -m venv venv
sourse venv/bin/activate

git clone https://github.com/microsoft/OmniParser.git
cd OmniParser

pip install -r requirements.txt


# download the model checkpoints to local directory OmniParser/weights/
for f in icon_detect/{train_args.yaml,model.pt,model.yaml} icon_caption/{config.json,generation_config.json,model.safetensors}; do huggingface-cli download microsoft/OmniParser-v2.0 "$f" --local-dir weights; done
mv weights/icon_caption weights/icon_caption_florence

# run demo
python gradio_demo.py