import joblib import pandas as pd import numpy as np import os # load RF model model_path = os.path.join(os.path.dirname(__file__), 'rf_dct.pkl') model = joblib.load(model_path) # Read CSV def read_csv(filename, rows=1000): df = pd.read_csv(filename, nrows=rows) features = df.iloc[:,1:] # Extract features (DCT features) return features # function to reshape the features (32x32 patches for each RGB channel) def reshape_features(features): red_c = features.iloc[:, :1024].to_numpy().reshape(-1, 32, 32) # First 1024 for Red green_c = features.iloc[:, 1024:2048].to_numpy().reshape(-1, 32, 32) # Next 1024 for Green blue_c = features.iloc[:, 2048:].to_numpy().reshape(-1, 32, 32) # Last columns for Blue return red_c, green_c, blue_c