HumanSignal / label-studio-ml-backend

Configs and boilerplates for Label Studio's Machine Learning backend
Apache License 2.0
585 stars 261 forks source link

使用SAM进行分割没有反应 #572

Closed moyue358 closed 5 months ago

moyue358 commented 5 months ago

我按照这个“https://labelstud.io/blog/get-started-using-segment-anything/#announcing-an-update-to-the-segment-anything-label-studio-backend” 网页的教程进行操作。在label-studio的项目的设置中,models选项里显示是与后端保持connected,但是在打标签的界面使用auto-detect和指定标签进行分割,SAM模型似乎没有加载。 image 前端启动的部分终端内容:

qin@user-Super-Server:~/Projects/label-studio-ml-backend/label_studio_ml/examples/segment_anything_model$ docker run -it -p 8080:8080     -v /mnt/data/GTAV-dataset/label-studio/mydata:/label-studio/data     --env LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true     --env LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/label-studio/data/images     heartexlabs/label-studio:latestst
=> Database and media directory: /label-studio/data
=> Static URL is set to: /static/
=> Database and media directory: /label-studio/data
=> Static URL is set to: /static/
Read environment variables from: /label-studio/data/.env
get 'SECRET_KEY' casted as '<class 'str'>' with default ''
[Tracing] Create new propagation context: {'trace_id': 'f3545253661b4b6a95d3dd2326a691df', 'span_id': '8c1ccf6744101799', 'parent_span_id': None, 'dynamic_sampling_context': None}
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /pypi/label-studio/json HTTP/1.1" 200 32193
Performing system checks...

System check identified no issues (1 silenced).
June 22, 2024 - 01:21:25
Django version 3.2.25, using settings 'core.settings.label_studio'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.
[2024-06-22 01:21:27,192] [django.server::log_message::161] [INFO] "GET / HTTP/1.1" 302 0
[2024-06-22 01:21:27,192] [django.server::log_message::161] [INFO] "GET / HTTP/1.1" 302 0
[2024-06-22 01:21:27,274] [django.server::log_message::161] [INFO] "GET /user/login/ HTTP/1.1" 200 5402
[2024-06-22 01:21:27,274] [django.server::log_message::161] [INFO] "GET /user/login/ HTTP/1.1" 200 5402
[2024-06-22 01:21:27,403] [django.server::log_message::161] [INFO] "GET /static/css/main.05101f5b0b98.css HTTP/1.1" 200 15255
[2024-06-22 01:21:27,403] [django.server::log_message::161] [INFO] "GET /static/css/main.05101f5b0b98.css HTTP/1.1" 200 15255
[2024-06-22 01:21:27,404] [django.server::log_message::161] [INFO] "GET /react-app/main.css?v=779ee9 HTTP/1.1" 200 79666
[2024-06-22 01:21:27,404] [django.server::log_message::161] [INFO] "GET /react-app/main.css?v=779ee9 HTTP/1.1" 200 79666
[2024-06-22 01:21:27,555] [django.server::log_message::161] [INFO] "GET /static/css/login.8194c7aa01b8.css HTTP/1.1" 200 6270
[2024-06-22 01:21:27,555] [django.server::log_message::161] [INFO] "GET /static/css/login.8194c7aa01b8.css HTTP/1.1" 200 6270
[2024-06-22 01:21:28,003] [django.server::log_message::161] [INFO] "GET /static/images/heidi-tip.2e3228516929.svg HTTP/1.1" 200 39408

docker-compose.yml文件内容:

version: "3.8"

services:
  segment_anything_model:
    container_name: segment_anything_model
    image: heartexlabs/label-studio-ml-backend:sam-master
    build:
      context: .
      shm_size: '4gb'
      args:
        TEST_ENV: ${TEST_ENV}
    deploy:
      resources:
        limits:
            memory: 8G
        reservations:
            memory: 4G
            devices:
              - driver: nvidia
                count: 4
                capabilities: [gpu]
    environment:
      # specify these parameters if you want to use basic auth for the model server
      - BASIC_AUTH_USER=
      - BASIC_AUTH_PASS=
      # Change this to your model name: MobileSAM or SAM
      - SAM_CHOICE=SAM
      - LOG_LEVEL=DEBUG
      # Enable this to use the GPU
      - NVIDIA_VISIBLE_DEVICES=all
      # specify the number of workers and threads for the model server
      - WORKERS=1
      - THREADS=8
      # specify the model directory (likely you don't need to change this)
      - MODEL_DIR=/data/models

      # Specify the Label Studio URL and API key to access
      # uploaded, local storage and cloud storage files.
      # Do not use 'localhost' as it does not work within Docker containers.
      # Use prefix 'http://' or 'https://' for the URL always.
      # Determine the actual IP using 'ifconfig' (Linux/Mac) or 'ipconfig' (Windows).
      - LABEL_STUDIO_HOST=http://****:8080
      - LABEL_STUDIO_ACCESS_TOKEN=****

    ports:
      - 9090:9090
    volumes:
      - "./data/server:/data"

后端启动的终端部分内容:

qin@user-Super-Server:~/Projects/label-studio-ml-backend/label_studio_ml/examples/segment_anything_model$ docker compose up
WARN[0000] The "TEST_ENV" variable is not set. Defaulting to a blank string. 
WARN[0000] /home/qin/Projects/label-studio-ml-backend/label_studio_ml/examples/segment_anything_model/docker-compose.yml: `version` is obsolete 
[+] Running 1/0
 ✔ Container segment_anything_model  Recreated                                                                          0.0s 
Attaching to segment_anything_model
segment_anything_model  | [2024-06-22 01:23:13 +0000] [7] [INFO] Starting gunicorn 22.0.0
segment_anything_model  | [2024-06-22 01:23:13 +0000] [7] [INFO] Listening at: http://0.0.0.0:9090 (7)
segment_anything_model  | [2024-06-22 01:23:13 +0000] [7] [INFO] Using worker: gthread
segment_anything_model  | [2024-06-22 01:23:13 +0000] [9] [INFO] Booting worker with pid: 9
segment_anything_model  | /usr/local/lib/python3.8/site-packages/pydantic/_internal/_config.py:334: UserWarning: Valid config keys have changed in V2:
segment_anything_model  | * 'allow_population_by_field_name' has been renamed to 'populate_by_name'
segment_anything_model  |   warnings.warn(message, UserWarning)
segment_anything_model  | /usr/local/lib/python3.8/site-packages/pydantic/_internal/_fields.py:160: UserWarning: Field "model_version" has conflict with protected namespace "model_".
segment_anything_model  | 
segment_anything_model  | You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
segment_anything_model  |   warnings.warn(
segment_anything_model  | [2024-06-22 01:23:16,542] [DEBUG] [sam_predictor::__init__::36] Using device cuda
segment_anything_model  | [2024-06-22 01:23:16,658] [INFO] [sam_predictor::__init__::59] Using SAM checkpoint /app/models/sam_vit_h_4b8939.pth
segment_anything_model  | [2024-06-22 01:23:23,142] [DEBUG] [label_studio_ml.api::log_request_info::179] Request headers: Host: localhost:9090
segment_anything_model  | Connection: keep-alive
segment_anything_model  | Sec-Ch-Ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"
segment_anything_model  | Sec-Ch-Ua-Mobile: ?0
segment_anything_model  | Sec-Ch-Ua-Platform: "Windows"
segment_anything_model  | Upgrade-Insecure-Requests: 1
segment_anything_model  | User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
segment_anything_model  | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
segment_anything_model  | Sec-Fetch-Site: none
segment_anything_model  | Sec-Fetch-Mode: navigate
segment_anything_model  | Sec-Fetch-User: ?1
segment_anything_model  | Sec-Fetch-Dest: document
segment_anything_model  | Accept-Encoding: gzip, deflate, br, zstd
segment_anything_model  | Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
segment_anything_model  | Cookie: username-localhost-8889="2|1:0|10:1717632496|23:username-localhost-8889|44:ZmNjNDg4MjIxYTYxNDY1OTk0MjAyYmQ2MzkyMTUxMTg=|7d348a24c93e522e230fc4c67f5b41b34e909f8f6d66b6206604c66402179093"; _xsrf=2|45ff2730|f32db1ad66796843e679f4ffd3540700|1717632496; _ga=GA1.1.2108444228.1718887086; _gid=GA1.1.1282437830.1719018689; _gat_gtag_UA_129877673_1=1; csrftoken=O9ruc2t2NChdmlMHGkY2jYA5vb6KRqA6Jeov6gihCetYJyGZHMLymGswsWQ5oOBB; _ga_Z4KXEBY4VP=GS1.1.1719018689.2.1.1719019353.57.0.0; sessionid=.eJxVT8tuhCAU_RfWanheBpfd9xvM5QJKx8BENOkj_fdqOptZnnfODztyYCMTAUQCBz2RDr2mKHu0ivqQpDOkHJH1rGN1m7Hkb9xzLdPjzkbRsRXbPq11zuWEVjgunDJicDcAJXTHJjz2ZTpa3Kb_KfbCeaR7LJcQPrDMdaBa9i374bIMT7UN7zXE9e3pfSlYsC1nWvnkkvEioQEExTXY4AA8KeIEynkrUCbk8SS00UoovKFF6bUmKThcpS22dj2Ln4-8fbFRK8k5__0Dp3xb0A:1sKpSe:YwUnI9C2m24wi1OH6BzsIQ2hGaqL54CVuj6R7QpxLZY
segment_anything_model  | 
segment_anything_model  | 
segment_anything_model  | [2024-06-22 01:23:23,142] [DEBUG] [label_studio_ml.api::log_request_info::180] Request body: b''
segment_anything_model  | [2024-06-22 01:23:23,143] [DEBUG] [label_studio_ml.api::log_response_info::185] Response status: 200 OK
segment_anything_model  | [2024-06-22 01:23:23,143] [DEBUG] [label_studio_ml.api::log_response_info::186] Response headers: Content-Type: application/json
segment_anything_model  | Content-Length: 45

我不清楚是哪里出现了问题,有人能帮忙解答吗,感谢!

moyue358 commented 5 months ago

按照教程格式修改了Labeling Interface,选中auto-detect和KeyPointLabel后可以有效分割