Spaces:
Running
Running
File size: 535 Bytes
b4f755d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import numpy as np
from .model_loader import load_model
model = load_model()
def classify_image(image: np.ndarray):
predictions = model.predict(image)[0]
human_conf = float(predictions[0])
ai_conf = float(predictions[1])
if ai_conf > 0.55:
label = "AI Generated"
elif ai_conf < 0.45:
label = "Human Generated"
else:
label = "Maybe AI"
return {
"label": label,
"ai_confidence": round(ai_conf * 100, 2),
"human_confidence": round(human_conf * 100, 2)
}
|