Metal3d commited on
Commit
db31bbc
·
1 Parent(s): dfcfb9f

Remove dead code

Browse files
Files changed (1) hide show
  1. packager.py +1 -41
packager.py CHANGED
@@ -63,47 +63,7 @@ def create_dataset_zip(
63
 
64
  return temp_path
65
 
66
- except Exception as e:
67
  # Clean up temp file if creation failed
68
  Path(temp_path).unlink(missing_ok=True)
69
- print(f"Error creating zip file: {e}")
70
- return None
71
-
72
- # Create a temporary file
73
- temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
74
- temp_path = temp_file.name
75
- temp_file.close()
76
-
77
- try:
78
- with zipfile.ZipFile(temp_path, "w", zipfile.ZIP_DEFLATED) as zip_file:
79
- for image_data in dataset.images:
80
- image_path = image_data["path"]
81
- label = image_data["label"]
82
-
83
- try:
84
- # Add the image file to zip
85
- with open(image_path, "rb") as img_file:
86
- zip_file.writestr(
87
- f"images/{Path(image_path).name}", img_file.read()
88
- )
89
-
90
- # Create and add the text file with the same base name
91
- base_name = Path(image_path).stem
92
- text_filename = f"labels/{base_name}.txt"
93
- zip_file.writestr(text_filename, label.encode("utf-8"))
94
-
95
- except FileNotFoundError:
96
- # Skip if image file doesn't exist
97
- continue
98
- except Exception as e:
99
- # Log error but continue with other files
100
- print(f"Error processing {image_path}: {e}")
101
- continue
102
-
103
- return temp_path
104
-
105
- except Exception as e:
106
- # Clean up temp file if creation failed
107
- Path(temp_path).unlink(missing_ok=True)
108
- print(f"Error creating zip file: {e}")
109
  return None
 
63
 
64
  return temp_path
65
 
66
+ except Exception:
67
  # Clean up temp file if creation failed
68
  Path(temp_path).unlink(missing_ok=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  return None