Browse Source

Add segmentation APIs

pull/1899/head
Hironsan 2 years ago
parent
commit
b281ab0a1c
2 changed files with 28 additions and 1 deletions
  1. 8
      backend/labels/urls.py
  2. 21
      backend/labels/views.py

8
backend/labels/urls.py

@ -7,6 +7,8 @@ from .views import (
CategoryListAPI,
RelationDetail,
RelationList,
SegmentationDetailAPI,
SegmentationListAPI,
SpanDetailAPI,
SpanListAPI,
TextLabelDetailAPI,
@ -40,4 +42,10 @@ urlpatterns = [
view=BoundingBoxDetailAPI.as_view(),
name="bbox_detail",
),
path(route="examples/<int:example_id>/segments", view=SegmentationListAPI.as_view(), name="segment_list"),
path(
route="examples/<int:example_id>/segments/<int:annotation_id>",
view=SegmentationDetailAPI.as_view(),
name="segment_detail",
),
]

21
backend/labels/views.py

@ -12,10 +12,19 @@ from .serializers import (
BoundingBoxSerializer,
CategorySerializer,
RelationSerializer,
SegmentationSerializer,
SpanSerializer,
TextLabelSerializer,
)
from labels.models import BoundingBox, Category, Label, Relation, Span, TextLabel
from labels.models import (
BoundingBox,
Category,
Label,
Relation,
Segmentation,
Span,
TextLabel,
)
from projects.models import Project
from projects.permissions import IsProjectMember
@ -122,3 +131,13 @@ class BoundingBoxListAPI(BaseListAPI):
class BoundingBoxDetailAPI(BaseDetailAPI):
queryset = BoundingBox.objects.all()
serializer_class = BoundingBoxSerializer
class SegmentationListAPI(BaseListAPI):
label_class = Segmentation
serializer_class = SegmentationSerializer
class SegmentationDetailAPI(BaseDetailAPI):
queryset = Segmentation.objects.all()
serializer_class = SegmentationSerializer
Loading…
Cancel
Save