Skip to content

Commit

Permalink
Updated Model representation to that of Geti V2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Daankrol committed Nov 28, 2024
1 parent 3bff8ea commit fd202ed
Show file tree
Hide file tree
Showing 14 changed files with 498 additions and 496 deletions.
7 changes: 4 additions & 3 deletions geti_sdk/data_models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class BaseModel:
]

name: str
fps_throughput: str
latency: str
precision: List[str]
creation_date: str = attr.field(converter=str_to_datetime)
latency: Optional[str] = None # Removed in Geti 2.6
fps_throughput: Optional[float] = None # Removed in Geti 2.6
purge_info: Optional[ModelPurgeInfo] = None
size: Optional[int] = None
target_device: Optional[str] = None
Expand Down Expand Up @@ -241,7 +241,8 @@ class Model(BaseModel):
"""

architecture: str = attr.field(kw_only=True)
score_up_to_date: bool = attr.field(kw_only=True)
# Removed in Geti 2.6
score_up_to_date: Optional[bool] = attr.field(default=None, kw_only=True)
optimized_models: List[OptimizedModel] = attr.field(kw_only=True)
# Removed in Geti 2.2
optimization_capabilities: Optional[OptimizationCapabilities] = attr.field(
Expand Down
3 changes: 2 additions & 1 deletion geti_sdk/data_models/model_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ModelSummary:

name: str
creation_date: str = attr.field(converter=str_to_datetime)
score_up_to_date: bool
score_up_to_date: Optional[bool] = None # Removed in Geti 2.6
purge_info: Optional[ModelPurgeInfo] = None
size: Optional[int] = None
version: Optional[int] = None # 'version' is removed in v1.1
Expand Down Expand Up @@ -74,6 +74,7 @@ class ModelGroup:
task_id: Optional[str] = attr.field(default=None)
id: Optional[str] = attr.field(default=None)
learning_approach: Optional[str] = attr.field(default=None) # Added in Geti v2.5
lifecycle_stage: Optional[str] = attr.field(default=None) # Added in Geti v2.6

def __attrs_post_init__(self) -> None:
"""
Expand Down
84 changes: 42 additions & 42 deletions notebooks/002_create_project_from_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "8269d231-cb5c-4591-b966-d0a00b9ef6f9",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.utils import get_server_details_from_env\n",
"\n",
"geti_server_configuration = get_server_details_from_env()"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
"id": "875581a5",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from geti_sdk import Geti\n",
"\n",
"geti = Geti(server_config=geti_server_configuration)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -66,15 +66,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "59176324-9c88-4110-a4be-0c99e194980a",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.demos import get_coco_dataset\n",
"\n",
"COCO_PATH = get_coco_dataset(dataset_path=None)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -87,17 +87,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "35c81a6b-7145-4707-b725-dba432efecf2",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.annotation_readers import DatumAnnotationReader\n",
"\n",
"annotation_reader = DatumAnnotationReader(\n",
" base_data_folder=COCO_PATH, annotation_format=\"coco\"\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -110,13 +110,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "4977c7bf-93e8-4ac9-b745-a7d8ac2859c5",
"metadata": {},
"outputs": [],
"source": [
"annotation_reader.filter_dataset(labels=[\"dog\", \"cat\", \"horse\"], criterion=\"OR\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -135,21 +135,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "349abb0f-14e1-40a4-877c-636675b23411",
"metadata": {},
"outputs": [],
"source": [
"PROJECT_NAME = \"COCO animal detection demo\"\n",
"PROJECT_TYPE = \"detection\""
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
"id": "d5a26174-effe-4600-b0c9-a177ff8ff01a",
"metadata": {},
"outputs": [],
"source": [
"project = geti.create_single_task_project_from_dataset(\n",
" project_name=PROJECT_NAME,\n",
Expand All @@ -160,7 +158,9 @@
" number_of_images_to_annotate=90,\n",
" enable_auto_train=True,\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -172,13 +172,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cd495e8-1c78-480f-9445-9082a4fa8429",
"metadata": {},
"outputs": [],
"source": [
"print(project.summary)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -199,10 +199,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ff6658a",
"metadata": {},
"outputs": [],
"source": [
"import csv\n",
"\n",
Expand All @@ -219,7 +217,9 @@
" first_data_line = next(reader)\n",
"print(header_line)\n",
"print(first_data_line)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -235,10 +235,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8f38ba6",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.rest_clients.project_client.project_client import ProjectClient\n",
"\n",
Expand All @@ -256,7 +254,9 @@
" CLASS_NAMES,\n",
" ],\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -268,15 +268,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "9866ef40",
"metadata": {},
"outputs": [],
"source": [
"all_labels = project.get_all_labels()\n",
"label_dict = {label.name: label for label in all_labels}\n",
"print(all_labels)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -288,10 +288,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "ba00d7d0",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.rest_clients.annotation_clients.annotation_client import AnnotationClient\n",
"from geti_sdk.rest_clients.media_client.image_client import ImageClient\n",
Expand All @@ -302,7 +300,9 @@
"annotation_client = AnnotationClient(\n",
" session=geti.session, workspace_id=geti.workspace_id, project=project\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -318,15 +318,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "88f92dc3",
"metadata": {},
"outputs": [],
"source": [
"image_path = first_data_line[0]\n",
"image_object = image_client.upload_image(image=COCO_PATH + image_path)\n",
"image_object"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -339,10 +339,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "c85bed24",
"metadata": {},
"outputs": [],
"source": [
"from geti_sdk.data_models.annotation_scene import AnnotationScene\n",
"from geti_sdk.data_models.annotations import Annotation\n",
Expand Down Expand Up @@ -379,7 +377,9 @@
" ]\n",
")\n",
"annotation_client.upload_annotation(image_object, annotation_scene)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down
Loading

0 comments on commit fd202ed

Please sign in to comment.