forked from supervisely-ecosystem/RT-DETR
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Local serving and meta.output update (#9)
* Local serving WIP * Refactor configuration and commands for RT-DETRv2 service * Update Dockerfile and configuration for RT-DETRv2: bump supervisely version to 6.73.307, update Docker image to 1.0.9, and increment instance version to 6.12.29 * Update Docker image version for RT-DETRv2 to 1.0.9 in docker-compose and configuration files
- Loading branch information
Showing
11 changed files
with
99 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
rtdetrv2: | ||
image: supervisely/rt-detrv2:1.0.9 | ||
shm_size: 1g | ||
runtime: nvidia | ||
env_file: | ||
- ~/supervisely.env | ||
environment: | ||
- PYTHONPATH=/app | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
ports: | ||
- "8000:8000" | ||
expose: | ||
- "8000" | ||
entrypoint: [ "python3", "supervisely_integration/serve/main.py" ] | ||
command: [ "--model", "RT-DETRv2-S" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
docker build -t supervisely/rt-detrv2:1.0.8 . && \ | ||
docker push supervisely/rt-detrv2:1.0.8 | ||
docker build -t supervisely/rt-detrv2:1.0.9 . && \ | ||
docker push supervisely/rt-detrv2:1.0.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
|
||
import supervisely as sly | ||
from supervisely_integration.serve.rtdetrv2 import RTDETRv2 | ||
|
||
if sly.is_development(): | ||
load_dotenv("local.env") | ||
load_dotenv(os.path.expanduser("~/supervisely.env")) | ||
|
||
api = sly.Api.from_env() | ||
|
||
################################ | ||
# 1. Serve with docker-compose # | ||
################################ | ||
# Run the following command in the terminal: | ||
# docker-compose up | ||
|
||
|
||
################################ | ||
# 2. Run with docker run # | ||
################################ | ||
# Run the following command in the terminal: | ||
# docker run \ | ||
# --shm-size=1g \ | ||
# --runtime=nvidia \ | ||
# --env-file ~/supervisely.env \ | ||
# --env PYTHONPATH=/app \ | ||
# -v ".:/app" \ | ||
# -w /app \ | ||
# -p 8000:8000 \ | ||
# supervisely/rt-detrv2:1.0.9 \ | ||
# python3 supervisely_integration/serve/main.py --model "RT-DETRv2-S" | ||
|
||
|
||
################################ | ||
# 3. Run locally # | ||
################################ | ||
# Run the following command in the terminal: | ||
# PYTHONPATH="${PWD}:${PYTHONPATH}" \ | ||
# python ./supervisely_integration/serve/main.py \ | ||
# --model "models/392_RT-DETRv2/checkpoints/best.pth" | ||
# --model "RT-DETRv2-S" | ||
|
||
################################### | ||
# How to use the serving session: # | ||
################################### | ||
|
||
# Connect to the serving session | ||
session = sly.nn.inference.Session(api, session_url="http://0.0.0.0:8000") | ||
|
||
img_path = "supervisely_integration/demo/img/coco_sample.jpg" | ||
ann = session.inference_image_path(img_path) | ||
|
||
# Display the annotated image | ||
img_preview_path = "supervisely_integration/demo/img/coco_sample_ann_preview.jpg" | ||
|
||
if os.path.exists(img_preview_path): | ||
os.remove(img_preview_path) | ||
|
||
# Read the image and draw the annotation | ||
img = sly.image.read(img_path) | ||
ann.draw_pretty(img) | ||
sly.image.write(img_preview_path, img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters