LPX55 commited on
Commit
9d94875
·
verified ·
1 Parent(s): 224d623

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -8,6 +8,7 @@ import pandas as pd
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,6 +36,7 @@ model_3 = AutoModelForImageClassification.from_pretrained(models[0]).to(device)
35
  feature_extractor_4 = AutoFeatureExtractor.from_pretrained(models[1])
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']
@@ -155,13 +157,20 @@ def predict_image(img, confidence_threshold):
155
  label_4 = "Uncertain Classification"
156
  except Exception as e:
157
  label_4 = f"Error: {str(e)}"
158
-
 
 
 
 
 
 
159
  # Combine results
160
  combined_results = {
161
  "SwinV2": label_1,
162
  "AI-vs-Real-Image-Detection": label_2,
163
  "Organika/sdxl-detector": label_3,
164
- "cmckinle/sdxl-flux-detector": label_4
 
165
  }
166
 
167
  return combined_results
 
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
  feature_extractor_4 = AutoFeatureExtractor.from_pretrained(models[1])
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']
 
157
  label_4 = "Uncertain Classification"
158
  except Exception as e:
159
  label_4 = f"Error: {str(e)}"
160
+
161
+ try:
162
+ pred = model.predict(np.expand_dims(img_pil / 255, 0))
163
+ result_5 = {
164
+ 'AI': pred[0],
165
+ 'Real': pred[1]
166
+ }
167
  # Combine results
168
  combined_results = {
169
  "SwinV2": label_1,
170
  "AI-vs-Real-Image-Detection": label_2,
171
  "Organika/sdxl-detector": label_3,
172
+ "cmckinle/sdxl-flux-detector": label_4,
173
+ "ALSv": label_5
174
  }
175
 
176
  return combined_results