Skip to content

Commit

Permalink
Merge pull request #49 from kauevestena/main
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-medeiros committed Jan 25, 2024
2 parents 134a48a + fb1e88d commit f4ca296
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM pytorch/pytorch:latest

# prevent apt from hanging
ARG DEBIAN_FRONTEND=noninteractive

# create workspace
ENV HOME /workspace
WORKDIR $HOME

# dependency: lang-segment-anything
RUN apt update

# installing system dependencies:
RUN apt install -y git
RUN apt install libgl1-mesa-glx -y
RUN apt install libglib2.0-0 -y

# copy source code:
COPY . $HOME/lang-segment-anything

# installing python dependencies:
WORKDIR $HOME/lang-segment-anything
RUN pip install -e .

# running the basic test,
# then it will held the weights inside the image,
# so no "cold start"
RUN python running_test.py

# running the app:
CMD ["lightning", "run", "app", "app.py"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ conda env create -f environment.yml
conda activate lsa
```

#### Docker Installation

Build and run the image.

```
docker build --tag lang-segment-anything:latest .
docker run --gpus all -it lang-segment-anything:latest
```

If you want a shared folder you can add a volume with `-v <host_source_dir>:<container_dest_dir>` example: `-v ./data:/workspace/data`


### Usage

Expand Down
14 changes: 14 additions & 0 deletions running_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'''
This is just adapted from the example in the readme,
The main usage is for the built image to have the weights cached.
'''

from PIL import Image
from lang_sam import LangSAM

model = LangSAM()
image_pil = Image.open("./assets/car.jpeg").convert("RGB")
text_prompt = "wheel"
masks, boxes, phrases, logits = model.predict(image_pil, text_prompt)

print('all ok')

0 comments on commit f4ca296

Please sign in to comment.