53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
import os
|
|
import json
|
|
|
|
def main():
|
|
to_delete = [
|
|
"IMG_20260701_134635.jpg",
|
|
"IMG_20260701_134636.jpg"
|
|
]
|
|
|
|
base_dir = "backend"
|
|
if not os.path.exists(base_dir):
|
|
base_dir = "."
|
|
|
|
uploads_dir = os.path.join(base_dir, "uploads")
|
|
public_dir = os.path.join(base_dir, "pfm-web-app/public")
|
|
|
|
for filename in to_delete:
|
|
# Delete manual label json
|
|
ml_path = os.path.join(uploads_dir, f"manual_label_{filename}.json")
|
|
if os.path.exists(ml_path):
|
|
os.remove(ml_path)
|
|
print(f"Deleted: {ml_path}")
|
|
|
|
# Delete public image
|
|
img_public_path = os.path.join(public_dir, "test-images", filename)
|
|
if os.path.exists(img_public_path):
|
|
os.remove(img_public_path)
|
|
print(f"Deleted: {img_public_path}")
|
|
|
|
# Filter test_images_results.jsonl
|
|
jsonl_path = os.path.join(uploads_dir, "test_images_results.jsonl")
|
|
if os.path.exists(jsonl_path):
|
|
remaining_lines = []
|
|
with open(jsonl_path, "r", encoding="utf-8") as f:
|
|
for line in f:
|
|
if not line.strip():
|
|
continue
|
|
try:
|
|
data = json.loads(line)
|
|
fn = data.get("filename")
|
|
if fn not in to_delete:
|
|
remaining_lines.append(line)
|
|
except Exception as e:
|
|
print(f"Error parsing line: {e}")
|
|
remaining_lines.append(line)
|
|
|
|
with open(jsonl_path, "w", encoding="utf-8") as f:
|
|
f.writelines(remaining_lines)
|
|
print(f"Filtered results JSONL. Remaining entries: {len(remaining_lines)}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|