npng-lab / segmentation-model

Image segmentation with Deep Learning
0 stars 1 forks source link

[feature] xbd 유사 인스턴스 분할 추론 기능 #1

Open seunghyeokleeme opened 3 months ago

seunghyeokleeme commented 3 months ago

해당 함수 매개변수 및 반환타입

def prediction(input_img_path: str) -> List[{
  instance={
        "id": UUID,
        "mask_url": f'/static/{UUID}.png',
        "label": "building" | "background"
        "box_coordinates": [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]  # 좌상, 우상, 우하, 좌하
    }
}]

@jihoon2819 님 올린 추론용 코드를 기반으로 작업 진행 https://github.com/sibas-lab/segmentation-model/commit/513c92e0354c24c39c8b6de61651039c1795fc49

요구사항

seunghyeokleeme commented 3 months ago

해당 함수 매개변수 및 반환타입을 명시적으로 선언 및 유효성 검증을 위해 다음과 같이 작성하면 좋습니다.

from typing import List, Tuple, Dict, Any
from uuid import UUID, uuid4
from dataclasses import dataclass, asdict

@dataclass
class Instance:
    id: UUID
    mask_url: str
    box_coordinates: List[Tuple[int, int]]

def validate_instance(instance: Instance) -> bool:
    if not isinstance(instance.id, UUID):
        return False
    if not isinstance(instance.mask_url, str):
        return False
    if not isinstance(instance.box_coordinates, list):
        return False
    if not all(isinstance(coord, tuple) and len(coord) == 2 for coord in instance.box_coordinates):
        return False
    return True

def prediction(input_img_path: str) -> List[Instance]:
  instance_info: List[Instance] = []
  pass # 여기부터 작업 시작