|
|
@@ -14,7 +14,7 @@ export class PalmOilService {
|
|
|
private readonly scanner: ScannerProvider,
|
|
|
@InjectRepository(History)
|
|
|
private readonly historyRepository: Repository<History>,
|
|
|
- ) {}
|
|
|
+ ) { }
|
|
|
|
|
|
async analyzeImage(imageBuffer: Buffer, originalFilename: string = 'unknown.jpg'): Promise<AnalysisResponse> {
|
|
|
const processingStart = performance.now();
|
|
|
@@ -52,7 +52,7 @@ export class PalmOilService {
|
|
|
industrialSummary[det.class] = (industrialSummary[det.class] || 0) + 1;
|
|
|
});
|
|
|
|
|
|
- console.log('📊 Industrial Summary:', industrialSummary);
|
|
|
+ // console.log('📊 Industrial Summary:', industrialSummary);
|
|
|
|
|
|
const processingMs = performance.now() - processingStart;
|
|
|
const archiveId = `palm_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
|
|
|
@@ -63,13 +63,13 @@ export class PalmOilService {
|
|
|
history.filename = originalFilename;
|
|
|
history.total_count = detections.length;
|
|
|
history.industrial_summary = industrialSummary;
|
|
|
-
|
|
|
+
|
|
|
// Ensure detections is an array of objects, not a leaked JSON string
|
|
|
history.detections = Array.isArray(detections) ? detections : [];
|
|
|
-
|
|
|
+
|
|
|
history.inference_ms = parseFloat(inferenceMs.toFixed(2));
|
|
|
history.processing_ms = parseFloat(processingMs.toFixed(2));
|
|
|
-
|
|
|
+
|
|
|
await this.historyRepository.save(history);
|
|
|
|
|
|
return {
|
|
|
@@ -78,6 +78,7 @@ export class PalmOilService {
|
|
|
total_count: detections.length,
|
|
|
industrial_summary: industrialSummary,
|
|
|
detections: history.detections,
|
|
|
+ image_data: `data:image/jpeg;base64,${imageBuffer.toString('base64')}`, // Pass the image back
|
|
|
inference_ms: history.inference_ms,
|
|
|
processing_ms: history.processing_ms,
|
|
|
archive_id: archiveId,
|