Browse Source

Add image classification to upload catalog

pull/1370/head
Hironsan 4 years ago
parent
commit
9aa53bf283
3 changed files with 17 additions and 1 deletions
  1. 2
      backend/api/models.py
  2. 10
      backend/api/views/upload/catalog.py
  3. 6
      backend/api/views/upload/examples.py

2
backend/api/models.py

@ -13,11 +13,13 @@ DOCUMENT_CLASSIFICATION = 'DocumentClassification'
SEQUENCE_LABELING = 'SequenceLabeling'
SEQ2SEQ = 'Seq2seq'
SPEECH2TEXT = 'Speech2text'
IMAGE_CLASSIFICATION = 'ImageClassification'
PROJECT_CHOICES = (
(DOCUMENT_CLASSIFICATION, 'document classification'),
(SEQUENCE_LABELING, 'sequence labeling'),
(SEQ2SEQ, 'sequence to sequence'),
(SPEECH2TEXT, 'speech to text'),
(IMAGE_CLASSIFICATION, 'image classification')
)

10
backend/api/views/upload/catalog.py

@ -4,7 +4,7 @@ from typing import Dict, List, Type
from pydantic import BaseModel
from typing_extensions import Literal
from ...models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from ...models import DOCUMENT_CLASSIFICATION, IMAGE_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from . import examples
encodings = Literal[
@ -162,6 +162,11 @@ class CoNLL(Format):
accept_types = 'text/*'
class ImageFile(Format):
name = 'ImageFile'
accept_types = 'image/png, image/jpeg, image/bmp, image/gif'
class OptionColumn(BaseModel):
encoding: encodings = 'utf_8'
column_data: str = 'text'
@ -228,3 +233,6 @@ Options.register(SEQ2SEQ, CSV, OptionDelimiter, examples.Text_CSV)
Options.register(SEQ2SEQ, JSON, OptionColumn, examples.Text_JSON)
Options.register(SEQ2SEQ, JSONL, OptionColumn, examples.Text_JSONL)
Options.register(SEQ2SEQ, Excel, OptionColumn, examples.Text_CSV)
# Image classification
Options.register(IMAGE_CLASSIFICATION, ImageFile, OptionNone, examples.Generic_ImageFile)

6
backend/api/views/upload/examples.py

@ -4,6 +4,12 @@ Generic_TextFile = """
202104210945.txt
"""
Generic_ImageFile = """
202104210943.png
202104210944.png
202104210945.png
"""
Generic_TextLine = """
Terrible customer service.
Really great transaction.

Loading…
Cancel
Save