feat: make manual-images list dynamic and resolve checkmark encoding issues
This commit is contained in:
1 parent
a211593f2c
commit
43e6eea253
7 files changed
+57
-40
No files matched your search
@@ -27,7 +27,7 @@ def main():
|
||||
|
||||
# Load automated results
|
||||
auto_results = {}
|
||||
with open(jsonl_file, "r") as f:
|
||||
with open(jsonl_file, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if not line.strip():
|
||||
continue
|
||||
@@ -44,7 +44,7 @@ def main():
|
||||
manual_labels = {}
|
||||
for mf in manual_files:
|
||||
try:
|
||||
with open(mf, "r") as f:
|
||||
with open(mf, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
filename = data.get("filename")
|
||||
if filename:
|
||||
|
||||
@@ -23,7 +23,7 @@ def main():
|
||||
|
||||
for mf in sorted(manual_files):
|
||||
try:
|
||||
with open(mf, "r") as f:
|
||||
with open(mf, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
manual_list.append(data)
|
||||
except Exception as e:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import glob
|
||||
|
||||
def main():
|
||||
uploads_dir = "backend/uploads"
|
||||
if not os.path.exists(uploads_dir):
|
||||
uploads_dir = "uploads"
|
||||
|
||||
manual_pattern = os.path.join(uploads_dir, "manual_label_*.json")
|
||||
manual_files = glob.glob(manual_pattern)
|
||||
fixed_count = 0
|
||||
|
||||
for mf in manual_files:
|
||||
try:
|
||||
with open(mf, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
if "✓" in content:
|
||||
# Replace with the correct checkmark character
|
||||
content = content.replace("✓", "✓")
|
||||
|
||||
with open(mf, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
print(f"Fixed encoding corruption in: {mf}")
|
||||
fixed_count += 1
|
||||
except Exception as e:
|
||||
print(f"Error fixing {mf}: {e}")
|
||||
|
||||
print(f"Encoding fix completed. Files fixed: {fixed_count}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -17,7 +17,7 @@ def main():
|
||||
|
||||
for mf in manual_files:
|
||||
try:
|
||||
with open(mf, "r") as f:
|
||||
with open(mf, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
is_modified = False
|
||||
|
||||
Binary file not shown.
@@ -1,38 +1,22 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
const testFiles = [
|
||||
"1782870899198-sample_do.jpeg",
|
||||
"1782872141829-rotated_1782872118246_rotated_1782872112296_rotated_1782872107513_CAP3481952560331460805.jpg",
|
||||
"1782875271815-rotated_1782875258464_rotated_1782875254091_rotated_1782875250123_CAP1599226410575173446.jpg",
|
||||
"1782884664859-rotated_1782884661516_rotated_1782884658097_rotated_1782884654697_CAP5956452738616729026.jpg",
|
||||
"1782888127716-CAP6161747431193129837.jpg",
|
||||
"1782888211457-rotated_1782888204591_rotated_1782888199962_rotated_1782888195402_CAP7202641176939787142.jpg",
|
||||
"1782888609885-rotated_1782888593813_1000000454.jpg",
|
||||
"1782890303600-1000000465.jpg",
|
||||
"1782892728794-1000000466.jpg",
|
||||
"1782909791970-sample_do.jpeg",
|
||||
"IMG_20260630_145445.jpg",
|
||||
"IMG_20260701_134446.jpg",
|
||||
"IMG_20260701_134504.jpg",
|
||||
"IMG_20260701_134533.jpg",
|
||||
"IMG_20260701_134555.jpg",
|
||||
"IMG_20260701_134555~2.jpg",
|
||||
"IMG_20260701_134635.jpg",
|
||||
"IMG_20260701_134636.jpg",
|
||||
"IMG_20260701_134646.jpg",
|
||||
"IMG_20260701_134646~2.jpg",
|
||||
"IMG_20260701_134704.jpg",
|
||||
"IMG_20260701_134704~2.jpg",
|
||||
"IMG_20260701_134810.jpg",
|
||||
"IMG_20260701_134817.jpg",
|
||||
"IMG_20260701_135900.jpg",
|
||||
"IMG_20260701_135910.jpg",
|
||||
"IMG_20260701_135923.jpg",
|
||||
"IMG_20260701_135938.jpg",
|
||||
"IMG_20260701_135950.jpg",
|
||||
"IMG_20260701_140005.jpg"
|
||||
];
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json({ files: testFiles });
|
||||
try {
|
||||
const dirPath = path.join(process.cwd(), "public/test-images");
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
return NextResponse.json({ files: [] });
|
||||
}
|
||||
const files = fs.readdirSync(dirPath).filter(file => {
|
||||
const ext = path.extname(file).toLowerCase();
|
||||
return ext === ".jpg" || ext === ".jpeg" || ext === ".png";
|
||||
});
|
||||
// Sort files to keep consistent ordering in UI
|
||||
files.sort();
|
||||
return NextResponse.json({ files });
|
||||
} catch (error: any) {
|
||||
console.error("Error reading test-images directory:", error);
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@
|
||||
"kodeBarang": "21002601",
|
||||
"namaBarang": "Prima Nasi Spicy Chick Sambal Geprek COPY",
|
||||
"banyak": "1 80X",
|
||||
"jumlah": "6 PAC✓"
|
||||
"jumlah": "6 PAC✓"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -338,7 +338,7 @@
|
||||
"kodeBarang": "11048000",
|
||||
"namaBarang": "BEBEK PARTING-NEW(*)",
|
||||
"banyak": "2 BOX",
|
||||
"jumlah": "30 PAC ✓"
|
||||
"jumlah": "30 PAC ✓"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user