diff --git a/backend/data_export/migrations/0002_exportedboundingbox.py b/backend/data_export/migrations/0002_exportedboundingbox.py index b4da4347..b5d0f331 100644 --- a/backend/data_export/migrations/0002_exportedboundingbox.py +++ b/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",), ), ] diff --git a/backend/projects/admin.py b/backend/projects/admin.py index 395a0ddc..f76e4a63 100644 --- a/backend/projects/admin.py +++ b/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) diff --git a/backend/projects/migrations/0006_segmentationproject_alter_project_project_type.py b/backend/projects/migrations/0006_segmentationproject_alter_project_project_type.py new file mode 100644 index 00000000..93af9341 --- /dev/null +++ b/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, + ), + ), + ] diff --git a/backend/projects/models.py b/backend/projects/models.py index d4e01326..eef75583 100644 --- a/backend/projects/models.py +++ b/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") diff --git a/backend/projects/serializers.py b/backend/projects/serializers.py index 61f33688..2b37e233 100644 --- a/backend/projects/serializers.py +++ b/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,