Skip to content

Commit 9ea815b

Browse files
authored
Merge pull request #128 from fastlabel/feature/1154-add-dataset-function
add datasets functions
2 parents dc56dbc + 479f548 commit 9ea815b

File tree

2 files changed

+450
-0
lines changed

2 files changed

+450
-0
lines changed

README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ _If you are using FastLabel prototype, please install version 0.2.2._
2727
- [labelme](#labelme)
2828
- [Segmentation](#segmentation)
2929
- [Converter to FastLabel format](#converter-to-fastlabel-format)
30+
- [Dataset](#dataset)
3031

3132
## Installation
3233

@@ -2105,6 +2106,198 @@ for image_file_path in glob.iglob(os.path.join(input_dataset_path, "**/**.jpg"),
21052106

21062107
> Please check const.COLOR_PALLETE for index colors.
21072108
2109+
## Dataset
2110+
2111+
### Create Dataset
2112+
2113+
Create a new dataset.
2114+
2115+
```python
2116+
dataset = client.create_dataset(
2117+
name="Japanese Dogs",
2118+
slug="japanese_dogs",
2119+
type="image"
2120+
)
2121+
```
2122+
2123+
#### Response Dataset
2124+
2125+
See API docs for details.
2126+
2127+
```python
2128+
{
2129+
'id': 'YOUR_DATASET_ID',
2130+
'name': 'Japanese Dogs',
2131+
'slug': 'japanese_dogs',
2132+
'type': 'image',
2133+
'createdAt': '2022-10-31T02:20:00.248Z',
2134+
'updatedAt': '2022-10-31T02:20:00.248Z'
2135+
}
2136+
```
2137+
2138+
### Find Dataset
2139+
2140+
Find a single dataset.
2141+
2142+
```python
2143+
dataset = client.find_dataset(dataset_id="YOUR_DATASET_ID")
2144+
```
2145+
2146+
Success response is the same as when created.
2147+
2148+
### Get Dataset
2149+
2150+
Get all datasets in the workspace. (Up to 1000 tasks)
2151+
2152+
```python
2153+
datasets = client.get_datasets()
2154+
```
2155+
2156+
The success response is the same as when created, but it is an array.
2157+
2158+
You can filter by type and keywords.
2159+
2160+
```python
2161+
datasets = client.get_datasets(
2162+
type="image", # 'image', 'video', 'audio'
2163+
keyword="dog"
2164+
)
2165+
```
2166+
2167+
If you wish to retrieve more than 1000 data sets, please refer to the Task [sample code](#get%20tasks).
2168+
2169+
### Update Dataset
2170+
2171+
Update a single dataset.
2172+
2173+
```python
2174+
dataset = client.update_dataset(
2175+
dataset_id="YOUR_DATASET_ID", name="World dogs"
2176+
)
2177+
```
2178+
2179+
Success response is the same as when created.
2180+
2181+
### Delete Dataset
2182+
2183+
Delete a single dataset.
2184+
2185+
**⚠️ The dataset object and its associated tasks that dataset has will also be deleted, so check carefully before executing.**
2186+
2187+
```python
2188+
client.delete_dataset(dataset_id="YOUR_DATASET_ID")
2189+
```
2190+
2191+
### Create Dataset Object
2192+
2193+
Create object in the dataset.
2194+
2195+
The types of objects that can be created are "image", "video", and "audio".
2196+
There are type-specific methods. but they can be used in the same way.
2197+
2198+
```python
2199+
dataset_object = client.create_image_dataset_object(
2200+
dataset_id="YOUR_DATASET_ID",
2201+
name="brushwood_dog.jpg",
2202+
file_path="./brushwood_dog.jpg",
2203+
)
2204+
```
2205+
2206+
#### Response Dataset Object
2207+
2208+
See API docs for details.
2209+
2210+
```python
2211+
{
2212+
'id': 'YOUR_DATASET_OBJECT_ID',
2213+
'name': 'brushwood_dog.jpg',
2214+
'size': 6717,
2215+
'height': 225,
2216+
'width': 225,
2217+
'groupId': None,
2218+
'createdAt': '2022-10-30T08:32:20.748Z',
2219+
'updatedAt': '2022-10-30T08:32:20.748Z'
2220+
}
2221+
```
2222+
2223+
### Find Dataset Object
2224+
2225+
Find a single dataset object.
2226+
2227+
```python
2228+
dataset_object = client.find_dataset_object(
2229+
dataset_object_id="YOUR_DATASET_OBJECT_ID"
2230+
)
2231+
```
2232+
2233+
Success response is the same as when created.
2234+
2235+
### Get Dataset Object
2236+
2237+
Get all dataset object in the dataset. (Up to 1000 tasks)
2238+
2239+
```python
2240+
dataset_objects = client.get_dataset_objects(dataset_id="YOUR_DATASET_ID")
2241+
```
2242+
2243+
The success response is the same as when created, but it is an array.
2244+
2245+
You can filter by keywords.
2246+
2247+
```python
2248+
dataset_objects = client.get_dataset_objects(
2249+
dataset_id="YOUR_DATASET_ID", keyword="dog"
2250+
)
2251+
```
2252+
2253+
If you wish to retrieve more than 1000 data sets, please refer to the Task [sample code](#get%20tasks).
2254+
2255+
### Delete Dataset Object
2256+
2257+
Delete a multi dataset objects.
2258+
2259+
**⚠️ Related tasks will also be deleted, so please check them carefully before execution.**
2260+
2261+
```python
2262+
client.delete_dataset_objects(
2263+
dataset_id="YOUR_DATASET_ID",
2264+
dataset_object_ids=[
2265+
"YOUR_DATASET_OBJECT_ID_1",
2266+
"YOUR_DATASET_OBJECT_ID_2",
2267+
],
2268+
)
2269+
```
2270+
2271+
### Get Import Histories For Dataset Object
2272+
2273+
Get all import histories in the dataset. (Up to 1000 tasks)
2274+
2275+
```python
2276+
datasets = client.get_dataset_object_import_histories(
2277+
dataset_id="YOUR_DATASET_ID"
2278+
)
2279+
```
2280+
2281+
#### Response Dataset Object Import Histories
2282+
2283+
See API docs for details.
2284+
2285+
```python
2286+
[
2287+
{
2288+
'id': 'YOUR_DATASET_OBJECT_IMPORT_HISTORY_ID',
2289+
'type': 'local',
2290+
'status': 'completed',
2291+
'msgCode': 'none',
2292+
'msgLevel': 'none',
2293+
'userName': 'admin',
2294+
'count': 1,
2295+
'createdAt': '2022-10-30T08:31:31.588Z',
2296+
'updatedAt': '2022-11-02T07:36:07.636Z'
2297+
}
2298+
]
2299+
```
2300+
21082301
## API Docs
21092302

21102303
Check [this](https://api.fastlabel.ai/docs/) for further information.

0 commit comments

Comments
 (0)