lyi029 commited on
Commit
cec1ee9
·
1 Parent(s): 90970fd
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -337,11 +337,27 @@ async def predict_malware(files: List[UploadFile] = File(...)):
337
  votes = [p["predicted_label"] for p in predictions]
338
  final_label, count = Counter(votes).most_common(1)[0]
339
 
 
 
 
 
 
 
 
 
 
 
 
340
  result = {
341
  "final_label": final_label,
342
  "vote_count": count,
343
  "total_segments": len(predictions),
344
  "confidence": sum(p["confidence"] for p in predictions) / len(predictions),
 
 
 
 
 
345
  "segment_predictions": predictions
346
  }
347
 
 
337
  votes = [p["predicted_label"] for p in predictions]
338
  final_label, count = Counter(votes).most_common(1)[0]
339
 
340
+ # result = {
341
+ # "final_label": final_label,
342
+ # "vote_count": count,
343
+ # "total_segments": len(predictions),
344
+ # "confidence": sum(p["confidence"] for p in predictions) / len(predictions),
345
+ # "segment_predictions": predictions
346
+ # }
347
+
348
+
349
+ best_embedding = max(all_embeddings, key=lambda x: x["attention_score"])
350
+
351
  result = {
352
  "final_label": final_label,
353
  "vote_count": count,
354
  "total_segments": len(predictions),
355
  "confidence": sum(p["confidence"] for p in predictions) / len(predictions),
356
+ "embedding": {
357
+ "values": best_embedding["embedding"],
358
+ "source_file": best_embedding["filename"],
359
+ "attention_score": best_embedding["attention_score"]
360
+ },
361
  "segment_predictions": predictions
362
  }
363