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

Fixes for YOLO indices, file formats and paths with special characters #132

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions pylabel/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ def _format_float(fl: float, fl_format: str):
return fl_format % fl

with open(file_path, "w") as f:
for _, row in df[columns].iterrows():
for row in df[columns].itertuples():
row=row[1:]
formatted_row = []
for x in row:
for x in row:
if isinstance(x, float):
formatted_row.append(_format_float(x, float_format))
elif isinstance(x, list):
Expand Down
11 changes: 9 additions & 2 deletions pylabel/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import json
import pandas as pd
import numpy as np
import xml.etree.ElementTree as ET
import os
from os.path import exists
Expand Down Expand Up @@ -261,7 +262,7 @@ def GetCatId(cat_name):

def ImportYoloV5(
path,
img_ext="jpg,jpeg,png",
img_ext="jpg,jpeg,png,webp",
cat_names=[],
path_to_images="",
name="dataset",
Expand Down Expand Up @@ -341,7 +342,13 @@ def GetCatNameFromId(cat_id, cat_names):

row["img_filename"] = image_filename

im = cv2.imread(str(image_path))
imgstream = open(str(image_path), "rb")
imgbytes = bytearray(imgstream.read())
numpyarray = np.asarray(imgbytes, dtype=np.uint8)

im = cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED)

#im = cv2.imread(str(image_path))
img_height, img_width, img_depth = im.shape

row["img_id"] = img_id
Expand Down
Loading