Basic Search#
TensorBay supports basic search based on different commits.
from tensorbay import GAS
# Please visit `https://gas.graviti.cn/tensorbay/developer` to get the AccessKey.
gas = GAS("<YOUR_ACCESSKEY>")
dataset_client = gas.create_dataset("<DATASET_NAME>")
BasicSearchJob#
TensorBay SDK allows create, get or list BasicSearchJob
via BasicSearch
.
Create#
A BasicSearchJob can be created by create_job()
dataset_client.basic_search.create_job(
title="search example",
description="search description",
conjunction="and",
unit="file",
filters=[
(
"category",
"in",
[
"human.pedestrian.adult",
"human.pedestrian.child",
"human.pedestrian.construction_worker",
],
"BOX3D",
),
("size", ">", 0),
("withLabel", "=", True),
("attribute", "in", {"attribute_1": [True, False], "attribute_2": [1, 2]}, "BOX3D"),
],
)
Note
conjunction
: The logical conjunction between search filters, which includes “and” and “or”.
Note
unit
:The unit of basic search. There are two options:“file”: Get the data that meets search filters;
“frame”: If at least one data in a frame meets search filters, all data in the frame will be get. This option only works on fusion dataset.
Note
filters
: The list of basic search criteria whose format is (key, operator, value, label_type).- key: The key of filters, which could be “segment”, “size”, “withLabel”, “frame”, “sensor”, “category”, “attribute” or “keyword”. Here, the meaning of the “keyword” is the remote path of the data, such as “cat_01.jpg”.
operator: The operational relationship between the key and value. The supported operators are “like”, “in”, “=”, “>”, “<”, “>=” and “<=”.
value: The value of filters.
label_type:It only needs to be used if the key is “category” or “attribute”, indicating the label type to which the category or attribute belongs.
There are also some restrictions on operators and values:
key
permitted operator
type of value
“segment”
“in”
list
“size”
“=”, “>”, “<”, “>=”, “<=”
int
“withLabel”
“=”
boolean
“frame”
“like”, “=”
string
“sensor”
“in”
list
“category”
“in”
list
“attribute”
“in”
dict
“keyword”
“like”, “=”
string
Get or List#
The latest BasicSearchJob can be obtained by get_job()
or list_jobs()
.
job = dataset_client.basic_search.get_job("<JOB_ID>")
job = dataset_client.basic_search.list_jobs()[0]
Get Information#
Available BasicSearchJob information includes title
, description
, job_id
, arguments
, created_at
, started_at
, finished_at
,
status
, error_message
and result
.
job.status
job.result
job.error_message
job.arguments
Note
If the BasicSearchJob is successfully completed, the result will be SearchResult
or FusionSearchResult
.
See more details in Search Result.
Important
Only the latest five search results for one dataset can be used.
Update#
The latest information of a BasicSearchJob can be obtained after update()
. Note that if the until_complete
is
set to True
, the BasicSearchJob will be blocked until it is completed.
job.update()
job.update(until_complete=True)
Abort#
BasicSearchJob also supports abort()
:
job.abort()
Create Dataset#
TensorBay SDK allows to create a dataset based on the search job by create_dataset()
job.create_dataset("<DATASET_NAME>")