I've set up a label studio instance with database and SAM ML backend. The model links with the label studio, and is reachable from the studio (Validate and Save passes). I've also set up the labeling with layout from the label studio SAM example . However, when I try to use a key point to label an object I get following error: No connection adapters were found for '172.20.0.4:8080/data/upload/5/b76sa08b.jpg'.
It seems to me that for some reason the model can't reach container with label studio instance. I've tried to set the LABEL_STUDIO_HOST var to other values, like name of the studio container. But with same results. I've also tried to run the SAM backend as a separate service, but that prevented me from even linking the model in label studio.
OS: Ubuntu 22.04
Docker compose version: 1.29.2
Label studio images: latest
SAM image: build from master
Trace:
sam_server | Traceback (most recent call last):
sam_server | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/exceptions.py", line 39, in exception_f
sam_server | return f(*args, **kwargs)
sam_server | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/api.py", line 61, in _predict
sam_server | predictions = model.predict(tasks, context=context, **params)
sam_server | File "/app/model.py", line 48, in predict
sam_server | predictor_results = PREDICTOR.predict(
sam_server | File "/app/sam_predictor.py", line 195, in predict
sam_server | return self.predict_sam(img_path, point_coords, point_labels, input_box)
sam_server | File "/app/sam_predictor.py", line 167, in predict_sam
sam_server | self.set_image(img_path, calculate_embeddings=False)
sam_server | File "/app/sam_predictor.py", line 83, in set_image
sam_server | image_path = get_image_local_path(
sam_server | File "/usr/local/lib/python3.8/site-packages/label_studio_ml/utils.py", line 64, in get_image_local_path
sam_server | image_local_path = get_local_path(
sam_server | File "/usr/local/lib/python3.8/site-packages/label_studio_tools/core/utils/io.py", line 104, in get_local_path
sam_server | r = requests.get(url, stream=True, headers=headers)
sam_server | File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 73, in get
sam_server | return request("get", url, params=params, **kwargs)
sam_server | File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 59, in request
sam_server | return session.request(method=method, url=url, **kwargs)
sam_server | File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
sam_server | resp = self.send(prep, **send_kwargs)
sam_server | File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 697, in send
sam_server | adapter = self.get_adapter(url=request.url)
sam_server | File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 794, in get_adapter
sam_server | raise InvalidSchema(f"No connection adapters were found for {url!r}")
sam_server | requests.exceptions.InvalidSchema: No connection adapters were found for '172.20.0.4:8080/data/upload/5/b76sa08b.jpg'
Compose File:
version: "3.9"
services:
app:
stdin_open: true
tty: true
build: .
image: heartexlabs/label-studio:latest
restart: unless-stopped
ports:
- "8080:8000"
depends_on:
- db
environment:
- DJANGO_DB=default
- POSTGRE_NAME=postgres
- POSTGRE_USER=postgres
- POSTGRE_PASSWORD=
- POSTGRE_PORT=5432
- POSTGRE_HOST=db
- LABEL_STUDIO_HOST=${LABEL_STUDIO_HOST:-}
- JSON_LOG=1
- LOG_LEVEL=DEBUG
volumes:
- ./mydata:/label-studio/data:rw
command: label-studio-uwsgi
networks:
- label_studio_network
db:
image: postgres:11.5
hostname: db
restart: unless-stopped
# Optional: Enable TLS on PostgreSQL
# Just drop your server.crt and server.key into folder 'deploy/pgsql/certs'
# NOTE: Both files must have permissions u=rw (0600) or less
# command: >
# -c ssl=on
# -c ssl_cert_file=/var/lib/postgresql/certs/server.crt
# -c ssl_key_file=/var/lib/postgresql/certs/server.key
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ${POSTGRES_DATA_DIR:-./postgres-data}:/var/lib/postgresql/data
- ./deploy/pgsql/certs:/var/lib/postgresql/certs:ro
networks:
- label_studio_network
sam_server:
container_name: sam_server
image: humansignal/sam:v0
build:
context: ./label-studio-ml-backend/label_studio_ml/examples/segment_anything_model
shm_size: '4gb'
deploy:
resources:
limits:
memory: 8G
reservations:
memory: 4G
environment:
# Change this to your model name
- SAM_CHOICE=MobileSAM
- LOG_LEVEL=DEBUG
# Add these variables if you want to access the images stored in Label Studio
- LABEL_STUDIO_HOST=127.0.0.1:8080
- LABEL_STUDIO_ACCESS_TOKEN=2f38a3ec675504af5ce79f34ded5915bd7af4432
ports:
- 9090:9090
volumes:
- "./data/server:/data"
networks:
- label_studio_network
networks:
label_studio_network:
Eventually I managed to resolve the issue by switching to host network and setting the LABEL_STUDIO_HOSTNAME to http://localhost:8080. Now the model predicts masks as expected.
I've set up a label studio instance with database and SAM ML backend. The model links with the label studio, and is reachable from the studio (Validate and Save passes). I've also set up the labeling with layout from the label studio SAM example . However, when I try to use a key point to label an object I get following error:
No connection adapters were found for '172.20.0.4:8080/data/upload/5/b76sa08b.jpg'
.It seems to me that for some reason the model can't reach container with label studio instance. I've tried to set the
LABEL_STUDIO_HOST
var to other values, like name of the studio container. But with same results. I've also tried to run the SAM backend as a separate service, but that prevented me from even linking the model in label studio.OS: Ubuntu 22.04 Docker compose version: 1.29.2 Label studio images: latest SAM image: build from master
Trace:
Compose File:
Network layout: