modal-omniparser

A serverless compute port of the OmniParser vision model for the Modal platform.
git clone https://unitehenry.com/git/modal-omniparser.git
Log | Files | Refs | README

commit 36a50eea75fe3233f064bfd2ed65f8cf262c759a
parent 609bbb1c9c40b5a6d9e07984e93ad2eddbefd006
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sat, 14 Mar 2026 03:54:51 +0000

feat: flash attention

Diffstat:
Msrc/app.py | 26+++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/src/app.py b/src/app.py @@ -27,10 +27,18 @@ image = ( "sed -i 's/\<torch\>/torch==2.2.0/g' requirements.txt", "sed -i 's/\<transformers\>/transformers==4.38.2/g' requirements.txt", "sed -i 's/\<paddlepaddle\>/paddlepaddle<=2.8/g' requirements.txt", - "$CONDA_DIR/bin/conda create -n 'omni' python==3.12 -y", + "$CONDA_DIR/bin/conda create -n omni python==3.12 -y", "$CONDA_DIR/bin/conda run -n omni pip install -r requirements.txt", + "$CONDA_DIR/bin/conda install -n omni cuda -c nvidia/label/cuda-12.1.0 -y", ] ) + .env({ + "PATH": "$CONDA_DIR/envs/omni/bin:$PATH", + "CUDA_HOME": "$CONDA_DIR/envs/omni" + }) + .run_commands([ + "$CONDA_DIR/bin/conda run -n omni pip install flash-attn==2.5.8 --no-build-isolation" + ]) .run_commands("curl -LsSf https://hf.co/cli/install.sh | bash") .run_commands( [ @@ -44,7 +52,6 @@ image = ( "mv weights/icon_caption weights/icon_caption_florence", ] ) - .env({"PATH": "$CONDA_DIR/envs/omni/bin:$PATH"}) ) @@ -89,21 +96,6 @@ def model_to_cuda(): som_model.to(device) print("model to {}".format(device)) - finally: - cleanup() - - -@app.function(gpu="h100", image=image, volumes={"/data": vol}) -def get_caption_model_processor(): - try: - setup() - - from util.utils import ( - get_som_labeled_img, - check_ocr_box, - get_caption_model_processor, - get_yolo_model, - ) get_caption_model_processor( model_name="florence2",