Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /autonomi-ai_nos /tests /models /openmmlab /test_mmdetection.py
| import pytest | |
| from loguru import logger | |
| from nos.constants import DEFAULT_GRPC_PORT | |
| from nos.server._runtime import InferenceServiceRuntime | |
| from nos.test.utils import NOS_TEST_IMAGE, PyTestGroup, skip_if_no_torch_cuda | |
| # See `nos.server._runtime.InferenceServiceRuntime` for `mmdet-dev` runtime spec | |
| RUNTIME_ENV = "mmdet-dev" | |
| pytestmark = pytest.mark.skipif(pytest.importorskip("mmdet") is None, reason="mmdet is not installed") | |
| def openmmlab_runtime(): | |
| runtime = InferenceServiceRuntime(runtime=RUNTIME_ENV, name=f"nos-{RUNTIME_ENV}-test") | |
| assert runtime is not None | |
| logger.debug(f"Starting inference service runtime: {RUNTIME_ENV}") | |
| runtime.start(ports={f"{DEFAULT_GRPC_PORT - 1}/tcp": DEFAULT_GRPC_PORT - 1}) | |
| assert runtime.get_container() is not None | |
| assert runtime.get_container_id() is not None | |
| assert runtime.get_container_name() is not None | |
| assert runtime.get_container_status() is not None | |
| yield runtime | |
| logger.debug(f"Stopping inference service runtime: {RUNTIME_ENV}") | |
| runtime.stop() | |
| logger.debug(f"Stopped inference service runtime: {RUNTIME_ENV}") | |
| def test_mmdetection_predict(model_name): | |
| from PIL import Image | |
| from nos.models import MMDetection | |
| model = MMDetection(model_name) | |
| img = Image.open(NOS_TEST_IMAGE) | |
| predictions = model([img, img]) | |
| assert predictions is not None | |
| assert predictions["scores"] is not None | |
| assert isinstance(predictions["scores"], list) | |
| assert len(predictions["scores"]) == 2 | |
| assert predictions["labels"] is not None | |
| assert isinstance(predictions["labels"], list) | |
| assert len(predictions["labels"]) == 2 | |
| assert predictions["bboxes"] is not None | |
| assert isinstance(predictions["bboxes"], list) | |
| assert len(predictions["bboxes"]) == 2 | |
| def test_mmdetection_benchmark(model_name): | |
| """Benchmark mmdetection models.""" | |
| raise NotImplementedError() | |
Xet Storage Details
- Size:
- 2.71 kB
- Xet hash:
- 27fdd5e0890536ff53efed0fa5ea5d0f24d9e74cb4de5a7bbccaa5d3fd1d64e2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.