Pujan-Dev's picture
feat: updated detector using Ela fft and meta
0b8f50d
raw
history blame contribute delete
520 Bytes
import numpy as np
import cv2
def preprocess_image(file):
# Read bytes from UploadFile
image_bytes = file.file.read()
# Convert bytes to NumPy array
nparr = np.frombuffer(image_bytes, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
if img is None:
raise ValueError("Could not decode image.")
img = cv2.resize(img, (256, 256)) # Changed size to 256x256
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = img / 255.0
img = np.expand_dims(img, axis=0)
return img