Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues #98 and #107 #108

Merged
merged 1 commit into from
May 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions pylabel/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def voc_xml_file_creation(
folder=True,
occluded=True,
):

index = 0
df_smaller = data[data["img_filename"] == file_name].reset_index()

Expand Down Expand Up @@ -381,7 +380,10 @@ def voc_xml_file_creation(
return output_file_path

# Loop through all images in the dataframe and call voc_xml_file_creation for each one
pbar = tqdm(desc="Exporting VOC files...", total=len(list(set(self.dataset.df.img_filename))))
pbar = tqdm(
desc="Exporting VOC files...",
total=len(list(set(self.dataset.df.img_filename))),
)
for file_title in list(set(self.dataset.df.img_filename)):
file_name = Path(file_title)
file_name = str(file_name.with_suffix(".xml"))
Expand Down Expand Up @@ -513,7 +515,6 @@ def ExportToYoloV5(

# If segmentation = False then export bounding boxes
if segmentation == False:

yolo_dataset["center_x_scaled"] = (
yolo_dataset["ann_bbox_xmin"] + (yolo_dataset["ann_bbox_width"] * 0.5)
) / yolo_dataset["img_width"]
Expand Down Expand Up @@ -561,7 +562,6 @@ def ExportToYoloV5(

# If segmentation = false then output bounding boxes
if segmentation == False:

df_single_img_annots.to_csv(
destination,
index=False,
Expand All @@ -583,7 +583,7 @@ def ExportToYoloV5(
with open(destination, "w") as file:
# Create one row per row in the data frame
for i in range(0, df_single_img_annots.shape[0]):
row = df_single_img_annots.iloc[i].cat_id
row = str(df_single_img_annots.iloc[i].cat_id)
segmentation_array = df_single_img_annots.iloc[
i
].ann_segmentation[0]
Expand Down Expand Up @@ -726,7 +726,6 @@ def ExportToCoco(self, output_path=None, cat_id_index=None):

# Skip this if cat_id is na
if not pd.isna(df["cat_id"][i]):

annotations = [
{
"image_id": df["img_id"][i],
Expand Down