Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import pandas as pd
|
|
8 |
import warnings
|
9 |
import math
|
10 |
import numpy as np
|
11 |
-
from tensorflow.keras.models import load_model
|
12 |
|
13 |
# Suppress warnings
|
14 |
warnings.filterwarnings("ignore", category=UserWarning, message="Using a slow image processor as `use_fast` is unset")
|
@@ -36,7 +35,6 @@ model_3 = AutoModelForImageClassification.from_pretrained(models[0]).to(device)
|
|
36 |
feature_extractor_4 = AutoFeatureExtractor.from_pretrained(models[1], device=device)
|
37 |
model_4 = AutoModelForImageClassification.from_pretrained(models[1]).to(device)
|
38 |
|
39 |
-
model_5 = load_model("large_model_3lakh_v1.h5")
|
40 |
# Define class names for all models
|
41 |
class_names_1 = ['artificial', 'real']
|
42 |
class_names_2 = ['AI Image', 'Real Image']
|
@@ -158,14 +156,14 @@ def predict_image(img, confidence_threshold):
|
|
158 |
except Exception as e:
|
159 |
label_4 = f"Error: {str(e)}"
|
160 |
|
161 |
-
try:
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
except Exception as e:
|
168 |
-
|
169 |
|
170 |
|
171 |
# Combine results
|
@@ -174,7 +172,7 @@ def predict_image(img, confidence_threshold):
|
|
174 |
"AI-vs-Real-Image-Detection": label_2,
|
175 |
"Organika/sdxl-detector": label_3,
|
176 |
"cmckinle/sdxl-flux-detector": label_4,
|
177 |
-
"ALSv": label_5
|
178 |
}
|
179 |
|
180 |
return combined_results
|
|
|
8 |
import warnings
|
9 |
import math
|
10 |
import numpy as np
|
|
|
11 |
|
12 |
# Suppress warnings
|
13 |
warnings.filterwarnings("ignore", category=UserWarning, message="Using a slow image processor as `use_fast` is unset")
|
|
|
35 |
feature_extractor_4 = AutoFeatureExtractor.from_pretrained(models[1], device=device)
|
36 |
model_4 = AutoModelForImageClassification.from_pretrained(models[1]).to(device)
|
37 |
|
|
|
38 |
# Define class names for all models
|
39 |
class_names_1 = ['artificial', 'real']
|
40 |
class_names_2 = ['AI Image', 'Real Image']
|
|
|
156 |
except Exception as e:
|
157 |
label_4 = f"Error: {str(e)}"
|
158 |
|
159 |
+
# try:
|
160 |
+
# pred = model.predict(np.expand_dims(img_pil / 255, 0))
|
161 |
+
# result_5 = {
|
162 |
+
# 'AI': pred[0],
|
163 |
+
# 'Real': pred[1]
|
164 |
+
# }
|
165 |
+
# except Exception as e:
|
166 |
+
# label_3 = f"Error: {str(e)}"
|
167 |
|
168 |
|
169 |
# Combine results
|
|
|
172 |
"AI-vs-Real-Image-Detection": label_2,
|
173 |
"Organika/sdxl-detector": label_3,
|
174 |
"cmckinle/sdxl-flux-detector": label_4,
|
175 |
+
# "ALSv": label_5
|
176 |
}
|
177 |
|
178 |
return combined_results
|