Skip to content

Commit 6b51add

Browse files
committed
final touches
1 parent 9d03492 commit 6b51add

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

README.md

+55-12
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,71 @@ Key files and classes include:
116116

117117
The SDK wraps the GraphQL APIs and provides a Pythonic interface for interacting with Labelbox.
118118

119+
## Contribution guidelines
120+
We encourage developers to contribute to the Labelbox Python SDK and help improve its functionality and usability. Please refer to the `CONTRIB.md` file in the root folder of the repository for detailed information on how to contribute.
121+
122+
## Develop with AI assistance
123+
### Load this repo code as context for large language models
124+
Using the [GPT repository loader](https://github.com/mpoon/gpt-repository-loader), we have created `lbx_prompt.txt` that contains data from all `.py` and `.md` files. The file has about 730k tokens. We recommend using Gemini 1.5 Pro with 1 million context length window
125+
126+
### Ask Google Gemini to get started
119127

120-
## Extending the SDK
128+
#### Extending the SDK
121129
The Labelbox Python SDK is designed to be extensible. Here are examples of how you can extend the SDK:
122130

123-
### Adding an Export Format Converter
131+
##### Adding an Export Format Converter
132+
###### Adding a method to convert export v2 to COCO format in Labelbox Python SDK
133+
134+
To add a method to the Labelbox Python SDK that converts export v2 into COCO format, you can follow these steps:
135+
136+
**1. Create a new Python file:**
137+
138+
Create a new file named `coco_converter.py` inside the `labelbox/schema/` directory. This file will contain the logic for converting export v2 data to COCO format.
139+
140+
**2. Implement the conversion logic:**
141+
142+
Inside `coco_converter.py`, define a function named `export_v2_to_coco`. This function should accept the export v2 data as input and perform the necessary conversion steps to generate the COCO format data structures. You can utilize existing libraries like `pycocotools` to achieve this.
143+
144+
Here's a basic example of how the function might look:
124145

125-
You can add a new export format converter by creating a class that inherits from the `Converter` class and implements the `convert` method. For example, to add a converter for a custom JSON format:
146+
```python
147+
from labelbox.schema.export_task import ExportTask
148+
from pycocotools.coco import COCO
149+
150+
def export_v2_to_coco(export_task: ExportTask) -> COCO:
151+
# Extract data from export_task
152+
# ...
153+
154+
# Convert data to COCO format using pycocotools
155+
# ...
156+
157+
# Return COCO object
158+
return coco_object
159+
```
160+
161+
**3. Add the method to the utilities module:**
162+
163+
Open the `labelbox/utilities.py` file and import the newly created `export_v2_to_coco` function. Then, add the function as a method to the `Utilities` class:
126164

127165
```python
128-
class CustomJsonConverter(Converter[CustomJsonOutput]):
166+
from labelbox.schema.coco_converter import export_v2_to_coco
129167

130-
def convert(self, input_args: Converter.ConverterInputArgs) -> Iterator[CustomJsonOutput]:
131-
# Implement logic to convert data to custom JSON format
132-
yield CustomJsonOutput(...)
168+
class Utilities:
169+
# ... existing methods ...
170+
171+
def export_v2_to_coco(self, export_task: ExportTask) -> COCO:
172+
return export_v2_to_coco(export_task)
133173
```
134174

135-
## Contribution guidelines
136-
We encourage developers to contribute to the Labelbox Python SDK and help improve its functionality and usability. Please refer to the `CONTRIB.md` file in the root folder of the repository for detailed information on how to contribute.
175+
**4. Update the documentation:**
137176

138-
## Develop with AI assistance
139-
### Load this repo code as context for large language models
140-
Using the [GPT repository loader](https://github.com/mpoon/gpt-repository-loader), we have created `lbx_prompt.txt` that contains data from all `.py` and `.md` files. The file has about 730k tokens. We recommend using Gemini 1.5 Pro with 1 million context length window
177+
Modify the README.md file to include information about the new `export_v2_to_coco` method in the `client.utilities` section. This will help users understand how to use the new functionality.
178+
179+
**5. Test the implementation:**
180+
181+
Write unit tests for the `export_v2_to_coco` function to ensure it works as expected with different export v2 data structures. This will help maintain the quality and reliability of the SDK.
182+
183+
By following these steps, you can successfully add a method to the Labelbox Python SDK that converts export v2 data to COCO format, making it readily available for users through `client.utilities.export_v2_to_coco()`.
141184

142185
## Documentation
143186
The Labelbox Python SDK is well-documented to help developers get started quickly and use the SDK effectively. Here are some resources:

0 commit comments

Comments
 (0)