forked from IQTLabs/SkyScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.py
91 lines (72 loc) · 2.56 KB
/
create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from labelbox import Client
from labelbox import Project
from labelbox import Dataset
import json
import os
# from: https://labelbox.com/docs/python-api/model-assisted-labeling-python-script
def turn_on_model_assisted_labeling(client: Client, project_id: str) -> None:
"""
Turns model assisted labeling on for the given project
Args:
client (Client): The client that is connected via API key
project_id (str): The id of the project
Returns:
None
"""
client.execute("""
mutation TurnPredictionsOn($proj_id: ID!){
project(
where: {id: $proj_id}
){
showPredictionsToLabelers(show:true){
id
showingPredictionsToLabelers
}
}
}
""", {"proj_id": project_id})
print("Connecting to Labelbox...")
client = Client(os.environ.get("LABELBOX_API_KEY"))
print("Creating Project: {}...".format(os.environ.get("LABELBOX_PROJECT_NAME")))
new_project = client.create_project(name=os.environ.get("LABELBOX_PROJECT_NAME"))
print("Creating Dataset: {}...".format(os.environ.get("LABELBOX_DATASET_NAME")))
new_dataset = client.create_dataset(name=os.environ.get("LABELBOX_DATASET_NAME"), projects = new_project)
new_dataset.create_data_row(row_data="./sample.jpg")
all_frontends = list(client.get_labeling_frontends())
for frontend in all_frontends:
if frontend.name == 'Editor':
new_project_frontend = frontend
break
new_project.labeling_frontend.connect(new_project_frontend)
print("Configuring Editor...")
ontology = {
"classifications": [
{"required": False,
"instructions": "Model",
"name": "model",
"type": "text",
"options":[]},
{"required": False,
"instructions": "Operator",
"name": "operator",
"type": "text",
"options":[]},
{"required": False,
"instructions": "Manufacturer",
"name": "manufacturer",
"type": "text",
"options":[]},
{"required": False,
"instructions": "ICAO24",
"name": "icao24",
"type": "text",
"options":[]}
]
}
new_project.setup(new_project_frontend, ontology)
new_project.datasets.connect(new_dataset)
print("Turning on Model Assisted Labeling..")
turn_on_model_assisted_labeling(client = client, project_id = new_project.uid)
print("\n\tSetup Complete!\n--------------------------")
print(f"The project id is: {new_project.uid}")
print(f"The dataset id is: {new_dataset.uid}")