Skip to content

Commit 067af74

Browse files
committed
Removed code from other branch
1 parent bb7c279 commit 067af74

File tree

1 file changed

+0
-113
lines changed
  • src/superannotate_databricks_connector

1 file changed

+0
-113
lines changed

src/superannotate_databricks_connector/vector.py

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -160,116 +160,3 @@ def get_vector_dataframe(annotations, spark, custom_id_map=None):
160160

161161
spark_df = spark.createDataFrame(rows, schema=schema)
162162
return spark_df
163-
164-
165-
def process_attribute(attribute):
166-
return {"groupName": attribute["groupName"],
167-
"name": attribute["name"]}
168-
169-
170-
def create_instance_dict(item):
171-
"""Funciton that unpacks a dataframe row converted into a dict
172-
and transformes it to a superannotate annotaiton dictionary
173-
174-
Arg:
175-
item (dict): dictionary with a instance in the superannotate-databricks
176-
format
177-
Returns:
178-
dict processed into superannotate json format
179-
"""
180-
item_dict = {
181-
"type": item["instance_type"],
182-
"classId": int(item["classId"]),
183-
"probability": item["probability"],
184-
"groupId": int(item["groupId"]),
185-
# "pointLabels": item.get("pointLabels", None), # uncomment if needed
186-
"locked": item["locked"],
187-
"trackingId": item["trackingId"],
188-
"attributes": [process_attribute(att) for att in item["attributes"]],
189-
"error": item["error"],
190-
"createdAt": item["createdAt"],
191-
"createdBy": item["createdBy"],
192-
"creationType": item["creationType"],
193-
"updatedAt": item["updatedAt"],
194-
"updatedBy": item["updatedBy"],
195-
"className": item["className"]
196-
}
197-
198-
instance_type = item["instance_type"]
199-
if instance_type in ["bbox", "rbbox"]:
200-
item_dict["points"] = item[instance_type].asDict()
201-
elif instance_type == "cuboid":
202-
item_dict["points"] = {k: v.asDict()
203-
for k, v in item["cuboid"].asDict().items()}
204-
elif instance_type == "polygon":
205-
item_dict["points"] = item["polygon"].asDict()["points"]
206-
item_dict["exclude"] = item["polygon"].asDict()["exclude"]
207-
elif instance_type == "point":
208-
item_dict["x"] = item["point"].asDict()["x"]
209-
item_dict["y"] = item["point"].asDict()["y"]
210-
elif instance_type == "ellipse":
211-
ellipse = item["ellipse"].asDict()
212-
item_dict["cx"] = ellipse["cx"]
213-
item_dict["cy"] = ellipse["cy"]
214-
item_dict["rx"] = ellipse["rx"]
215-
item_dict["ry"] = ellipse["ry"]
216-
item_dict["angle"] = ellipse["angle"]
217-
elif instance_type == "polyline":
218-
item_dict["points"] = item["polyline"]
219-
return item_dict
220-
221-
222-
def create_tag_dict(item):
223-
"""Funciton that unpacks a dataframe row converted into a dict
224-
and transformes it to a superannotate annotaiton dictionary
225-
226-
Arg:
227-
item (dict): dictionary with a tag in the superannotate-databricks
228-
format
229-
Returns:
230-
dict processed into superannotate json format
231-
"""
232-
item_dict = {
233-
"type": item["instance_type"],
234-
"classId": item["classId"],
235-
"probability": item["probability"],
236-
"attributes": [process_attribute(att) for att in item["attributes"]],
237-
"createdAt": item["createdAt"],
238-
"createdBy": item["createdBy"],
239-
"creationType": item["creationType"],
240-
"updatedAt": item["updatedAt"],
241-
"updatedBy": item["updatedBy"],
242-
"className": item["className"]
243-
}
244-
return item_dict
245-
246-
247-
def unpack_vector_row(row):
248-
"""Funciton that unpacks a dataframe row into a
249-
superannotate json ready to be uploaded
250-
251-
Arg:
252-
row (spark.sql.Row): row from superannotate formated dataframe
253-
Returns:
254-
dict processed into superannotate json format
255-
"""
256-
metadata = {"height": row["image_height"],
257-
"width": row["image_width"],
258-
"name": row["image_name"],
259-
"projectId": row["projectId"],
260-
"isPredicted": row["isPredicted"],
261-
"status": row["status"],
262-
"pinned": row["pinned"],
263-
"annotatorEmail": row["annotatorEmail"],
264-
"qaEmail": row["qaEmail"]}
265-
instances = []
266-
for instance in row["instances"]:
267-
instances.append(create_instance_dict(instance.asDict()))
268-
for tag in row["tags"]:
269-
instances.append(create_tag_dict(tag.asDict()))
270-
comments = []
271-
for comment in row["comments"]:
272-
comments.append(comment.asDict())
273-
return {"metadata": metadata,
274-
"instances": instances,
275-
"comments": comments}

0 commit comments

Comments
 (0)