Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,6 +118,19 @@ class ForgeryDetector:
|
|
| 118 |
if features.ndim == 1:
|
| 119 |
features = features.reshape(1, -1)
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
# Classify
|
| 122 |
predictions, confidences = self.classifier.predict(features)
|
| 123 |
forgery_type = int(predictions[0])
|
|
|
|
| 118 |
if features.ndim == 1:
|
| 119 |
features = features.reshape(1, -1)
|
| 120 |
|
| 121 |
+
# TEMPORARY FIX: Pad features to match classifier's expected count
|
| 122 |
+
expected_features = 526
|
| 123 |
+
current_features = features.shape[1]
|
| 124 |
+
if current_features < expected_features:
|
| 125 |
+
# Pad with zeros
|
| 126 |
+
padding = np.zeros((features.shape[0], expected_features - current_features))
|
| 127 |
+
features = np.hstack([features, padding])
|
| 128 |
+
print(f"Warning: Padded features from {current_features} to {expected_features}")
|
| 129 |
+
elif current_features > expected_features:
|
| 130 |
+
# Truncate
|
| 131 |
+
features = features[:, :expected_features]
|
| 132 |
+
print(f"Warning: Truncated features from {current_features} to {expected_features}")
|
| 133 |
+
|
| 134 |
# Classify
|
| 135 |
predictions, confidences = self.classifier.predict(features)
|
| 136 |
forgery_type = int(predictions[0])
|