t2d2-sdk 2.3.2__tar.gz → 2.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: t2d2-sdk
3
- Version: 2.3.2
3
+ Version: 2.3.3
4
4
  Summary: T2D2 SDK
5
5
  Author-email: Badri Hiriyur <badri@t2d2.ai>
6
6
  Project-URL: Homepage, https://t2d2.ai
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.3.2'
21
- __version_tuple__ = version_tuple = (2, 3, 2)
20
+ __version__ = version = '2.3.3'
21
+ __version_tuple__ = version_tuple = (2, 3, 3)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: t2d2-sdk
3
- Version: 2.3.2
3
+ Version: 2.3.3
4
4
  Summary: T2D2 SDK
5
5
  Author-email: Badri Hiriyur <badri@t2d2.ai>
6
6
  Project-URL: Homepage, https://t2d2.ai
@@ -2461,4 +2461,134 @@ class T2D2(object):
2461
2461
 
2462
2462
 
2463
2463
  url = "notifications/slack"
2464
- return self.request(url, RequestType.POST, data=payload)
2464
+ return self.request(url, RequestType.POST, data=payload)
2465
+
2466
+
2467
+ ################################################################################################
2468
+ # AI Models
2469
+ ################################################################################################
2470
+
2471
+ def get_ai_models(self):
2472
+ """
2473
+ Retrieve all AI models available in the current project.
2474
+
2475
+ This method fetches all AI models associated with the current project from the T2D2 API.
2476
+ It returns a list of dictionaries containing details about each AI model.
2477
+
2478
+ :return: A list of dictionaries, each containing AI model details
2479
+ :rtype: list of dict
2480
+
2481
+ :raises ValueError: If no project is currently set
2482
+ :raises ConnectionError: If there is a problem connecting to the T2D2 API
2483
+
2484
+ :example:
2485
+
2486
+ >>> models = client.get_ai_models()
2487
+ >>> print(models)
2488
+ """
2489
+ if not self.project:
2490
+ raise ValueError("Project not set")
2491
+
2492
+ url = f"{self.project['id']}/ai-models"
2493
+ return self.request(url, RequestType.GET)
2494
+
2495
+ def get_ai_model_by_id(self, model_id):
2496
+ """
2497
+ Retrieve details of a specific AI model by its ID.
2498
+
2499
+ This method fetches detailed information about a specific AI model from the T2D2 API.
2500
+ It returns a dictionary containing all the information available for the specified AI model.
2501
+
2502
+ :param model_id: The ID of the AI model to retrieve
2503
+ :type model_id: str
2504
+
2505
+ :return: A dictionary containing AI model details
2506
+ :rtype: dict
2507
+
2508
+ """
2509
+
2510
+ if not self.project:
2511
+ raise ValueError("Project not set")
2512
+
2513
+ url = f"{self.project['id']}/ai-models/{model_id}"
2514
+ return self.request(url, RequestType.GET)
2515
+
2516
+ def run_ai_inferencer(self, image_ids, model_id, confidence_threshold=0.5,
2517
+ replace_annotations=False, sliding_window=False,
2518
+ whole_image=True, batch_size=1):
2519
+ """
2520
+ Run AI inference on specified images using a selected model.
2521
+
2522
+ This method initiates an AI inference process on a set of images using the specified
2523
+ model. It constructs the payload with model details and user parameters, then sends
2524
+ the request to start the inference process.
2525
+
2526
+ :param image_ids: List of image IDs to run inference on
2527
+ :type image_ids: list of int
2528
+
2529
+ :param model_id: ID of the AI model to use for inference
2530
+ :type model_id: int
2531
+
2532
+ :param confidence_threshold: Minimum confidence score for detections (0.0 to 1.0)
2533
+ :type confidence_threshold: float
2534
+ :default confidence_threshold: 0.5
2535
+
2536
+ :param replace_annotations: Whether to replace existing annotations
2537
+ :type replace_annotations: bool
2538
+ :default replace_annotations: False
2539
+
2540
+ :param sliding_window: Whether to use sliding window approach for inference
2541
+ :type sliding_window: bool
2542
+ :default sliding_window: False
2543
+
2544
+ :param whole_image: Whether to process the whole image at once
2545
+ :type whole_image: bool
2546
+ :default whole_image: True
2547
+
2548
+ :param batch_size: Number of images to process in each batch
2549
+ :type batch_size: int
2550
+ :default batch_size: 1
2551
+
2552
+ :return: Response from the API containing the inference job details
2553
+ :rtype: dict
2554
+
2555
+ :raises ValueError: If no project is set or if required parameters are invalid
2556
+
2557
+ :example:
2558
+
2559
+ >>> image_ids = [602825, 602824, 602823]
2560
+ >>> result = client.run_ai_inferencer(
2561
+ ... image_ids=image_ids,
2562
+ ... model_id=1,
2563
+ ... confidence_threshold=0.6
2564
+ ... )
2565
+ >>> print(result)
2566
+ """
2567
+ if not self.project:
2568
+ raise ValueError("Project not set")
2569
+
2570
+ # Get model details
2571
+ model_details = self.get_ai_model_by_id(model_id)
2572
+ if not model_details["success"]:
2573
+ raise ValueError(f"Failed to get model details: {model_details.get('message', 'Unknown error')}")
2574
+
2575
+ model_data = model_details["data"]
2576
+
2577
+ # Construct payload
2578
+ payload = {
2579
+ "confidence_threshold": confidence_threshold,
2580
+ "replace_annotations": replace_annotations,
2581
+ "whole_image": whole_image,
2582
+ "batch_size": batch_size,
2583
+ "ai_model": model_id,
2584
+ "description": model_data["description"],
2585
+ "image_ids": image_ids,
2586
+ "labels": model_data["labels"],
2587
+ "sliding_window": sliding_window
2588
+ }
2589
+
2590
+ # Make request to start inference
2591
+ url = f"{self.project['id']}/tools/6/start"
2592
+ return self.request(url, RequestType.POST, data=payload)
2593
+
2594
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes