Browse Source

Add segmentation project

pull/1899/head
Hironsan 2 years ago
parent
commit
f80334f2e0
5 changed files with 86 additions and 9 deletions
  1. 17
      backend/data_export/migrations/0002_exportedboundingbox.py
  2. 4
      backend/projects/admin.py
  3. 52
      backend/projects/migrations/0006_segmentationproject_alter_project_project_type.py
  4. 16
      backend/projects/models.py
  5. 6
      backend/projects/serializers.py

17
backend/data_export/migrations/0002_exportedboundingbox.py

@ -6,20 +6,19 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('labels', '0015_create_boundingbox_table'),
('data_export', '0001_initial'),
("labels", "0015_create_boundingbox_table"),
("data_export", "0001_initial"),
]
operations = [
migrations.CreateModel(
name='ExportedBoundingBox',
fields=[
],
name="ExportedBoundingBox",
fields=[],
options={
'proxy': True,
'indexes': [],
'constraints': [],
"proxy": True,
"indexes": [],
"constraints": [],
},
bases=('labels.boundingbox',),
bases=("labels.boundingbox",),
),
]

4
backend/projects/admin.py

@ -1,8 +1,10 @@
from django.contrib import admin
from .models import (
BoundingBoxProject,
Member,
Project,
SegmentationProject,
Seq2seqProject,
SequenceLabelingProject,
Tag,
@ -43,4 +45,6 @@ admin.site.register(Project, ProjectAdmin)
admin.site.register(TextClassificationProject, ProjectAdmin)
admin.site.register(SequenceLabelingProject, ProjectAdmin)
admin.site.register(Seq2seqProject, ProjectAdmin)
admin.site.register(BoundingBoxProject, ProjectAdmin)
admin.site.register(SegmentationProject, ProjectAdmin)
admin.site.register(Tag, TagAdmin)

52
backend/projects/migrations/0006_segmentationproject_alter_project_project_type.py

@ -0,0 +1,52 @@
# Generated by Django 4.0.4 on 2022-06-30 04:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("projects", "0005_boundingboxproject_alter_project_project_type"),
]
operations = [
migrations.CreateModel(
name="SegmentationProject",
fields=[
(
"project_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="projects.project",
),
),
],
options={
"abstract": False,
"base_manager_name": "objects",
},
bases=("projects.project",),
),
migrations.AlterField(
model_name="project",
name="project_type",
field=models.CharField(
choices=[
("DocumentClassification", "document classification"),
("SequenceLabeling", "sequence labeling"),
("Seq2seq", "sequence to sequence"),
("IntentDetectionAndSlotFilling", "intent detection and slot filling"),
("Speech2text", "speech to text"),
("ImageClassification", "image classification"),
("BoundingBox", "bounding box"),
("Segmentation", "segmentation"),
],
max_length=30,
),
),
]

16
backend/projects/models.py

@ -15,6 +15,7 @@ SEQ2SEQ = "Seq2seq"
SPEECH2TEXT = "Speech2text"
IMAGE_CLASSIFICATION = "ImageClassification"
BOUNDING_BOX = "BoundingBox"
SEGMENTATION = "Segmentation"
INTENT_DETECTION_AND_SLOT_FILLING = "IntentDetectionAndSlotFilling"
PROJECT_CHOICES = (
(DOCUMENT_CLASSIFICATION, "document classification"),
@ -24,6 +25,7 @@ PROJECT_CHOICES = (
(SPEECH2TEXT, "speech to text"),
(IMAGE_CLASSIFICATION, "image classification"),
(BOUNDING_BOX, "bounding box"),
(SEGMENTATION, "segmentation"),
)
@ -170,6 +172,20 @@ class BoundingBoxProject(Project):
return True
class SegmentationProject(Project):
@property
def is_text_project(self) -> bool:
return False
@property
def can_define_label(self) -> bool:
return True
@property
def can_define_category(self) -> bool:
return True
class Tag(models.Model):
text = models.TextField()
project = models.ForeignKey(to=Project, on_delete=models.CASCADE, related_name="tags")

6
backend/projects/serializers.py

@ -7,6 +7,7 @@ from .models import (
IntentDetectionAndSlotFillingProject,
Member,
Project,
SegmentationProject,
Seq2seqProject,
SequenceLabelingProject,
Speech2textProject,
@ -126,6 +127,11 @@ class BoundingBoxProjectSerializer(ProjectSerializer):
model = BoundingBoxProject
class SegmentationProjectSerializer(ProjectSerializer):
class Meta(ProjectSerializer.Meta):
model = SegmentationProject
class ProjectPolymorphicSerializer(PolymorphicSerializer):
model_serializer_mapping = {
Project: ProjectSerializer,

Loading…
Cancel
Save