Spaces:
Sleeping
Sleeping
Remove dead code
Browse files62 unmodified lines6364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810962 unmodified linesreturn temp_pathexcept Exception as e:# Clean up temp file if creation failedPath(temp_path).unlink(missing_ok=True)print(f"Error creating zip file: {e}")return None# Create a temporary filetemp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")temp_path = temp_file.nametemp_file.close()try:with zipfile.ZipFile(temp_path, "w", zipfile.ZIP_DEFLATED) as zip_file:for image_data in dataset.images:image_path = image_data["path"]label = image_data["label"]try:# Add the image file to zipwith open(image_path, "rb") as img_file:zip_file.writestr(f"images/{Path(image_path).name}", img_file.read())# Create and add the text file with the same base namebase_name = Path(image_path).stemtext_filename = f"labels/{base_name}.txt"zip_file.writestr(text_filename, label.encode("utf-8"))except FileNotFoundError:# Skip if image file doesn't existcontinueexcept Exception as e:# Log error but continue with other filesprint(f"Error processing {image_path}: {e}")continuereturn temp_pathexcept Exception as e:# Clean up temp file if creation failedPath(temp_path).unlink(missing_ok=True)print(f"Error creating zip file: {e}")return None62 unmodified lines6364656667686962 unmodified linesreturn temp_pathexcept Exception:# Clean up temp file if creation failedPath(temp_path).unlink(missing_ok=True)return None
packager.py+1-41