Spaces:
Running
Running
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) | |
} | |