fix
This commit is contained in:
parent
b5d3683115
commit
0e9f1202cd
20
app.py
20
app.py
|
|
@ -407,9 +407,23 @@ def predict():
|
||||||
filepath = os.path.join(UPLOAD_FOLDER, filename)
|
filepath = os.path.join(UPLOAD_FOLDER, filename)
|
||||||
file.save(filepath)
|
file.save(filepath)
|
||||||
|
|
||||||
# File sudah di-validasi di frontend (/api/validate-image)
|
# Validasi ulang di backend supaya request langsung ke /predict tidak bisa bypass.
|
||||||
# Jangan validasi lagi, langsung lanjut ke diagnosis
|
is_cattle, validation_confidence, validation_reason = validate_cattle_image(
|
||||||
print(f"[PREDICT] ✅ File diterima dari frontend validation: {filename}")
|
filepath,
|
||||||
|
confidence_threshold=0.75,
|
||||||
|
)
|
||||||
|
if not is_cattle:
|
||||||
|
if os.path.exists(filepath):
|
||||||
|
try:
|
||||||
|
os.remove(filepath)
|
||||||
|
print(f"[PREDICT] ✓ File DIHAPUS (bukan sapi): {filename}")
|
||||||
|
except Exception as del_err:
|
||||||
|
print(f"[PREDICT] ⚠️ Error menghapus file non-sapi: {del_err}")
|
||||||
|
|
||||||
|
flash(validation_reason or 'Gambar selain sapi tidak diizinkan', 'error')
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
print(f"[PREDICT] ✅ File lolos validasi backend: {filename} ({validation_confidence*100:.0f}%)")
|
||||||
|
|
||||||
if not is_model_ready():
|
if not is_model_ready():
|
||||||
# Model belum siap - HAPUS FILE
|
# Model belum siap - HAPUS FILE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue