Update app.py
Browse files
app.py
CHANGED
@@ -225,28 +225,32 @@ with main_col_two:
|
|
225 |
if user_image is not None and model_name is not None:
|
226 |
predictions = []
|
227 |
# preprocess image and run the user selected model
|
228 |
-
if model_name
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
elif model_name == 'Efficientnet Art':
|
236 |
print('Effnet Art is running')
|
237 |
predictions = pre_process_img_effNetArt(user_image)
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
# display the result and the prediction
|
247 |
-
if user_image is not None:
|
248 |
-
if len(predictions) > 0:
|
249 |
-
result_placeholder.markdown(f"<div class='result'> <span class = 'prediction'>Prediction: {predictions[0][0]:.2%}</span> <br> It is a <span class = resultword> {result_word} </span> image. </div>", unsafe_allow_html=True)
|
250 |
|
251 |
print(model_name)
|
252 |
print(predictions[0])
|
|
|
225 |
if user_image is not None and model_name is not None:
|
226 |
predictions = []
|
227 |
# preprocess image and run the user selected model
|
228 |
+
if model_name != 'Efficientnet Art':
|
229 |
+
if model_name == 'CNN':
|
230 |
+
print('CNN is running')
|
231 |
+
predictions = pre_process_img(user_image)
|
232 |
+
elif model_name == 'Efficientnet':
|
233 |
+
print('Effnet is running')
|
234 |
+
predictions = pre_process_img_effNet(user_image)
|
235 |
+
if predictions[0] < 0.5:
|
236 |
+
result_word = "AI Generated"
|
237 |
+
else:
|
238 |
+
result_word = "REAL"
|
239 |
+
if user_image is not None:
|
240 |
+
if len(predictions) > 0:
|
241 |
+
result_placeholder.markdown(f"<div class='result'> <span class = 'prediction'>Prediction: {predictions[0][0]:.2%}</span> <br> It is a <span class = resultword> {result_word} </span> image. </div>", unsafe_allow_html=True)
|
242 |
|
243 |
elif model_name == 'Efficientnet Art':
|
244 |
print('Effnet Art is running')
|
245 |
predictions = pre_process_img_effNetArt(user_image)
|
246 |
+
scaled_prediction = min(predictions[0][0] * 10000, 1)
|
247 |
+
if scaled_prediction < 0.5:
|
248 |
+
result_word = "AI Generated"
|
249 |
+
else:
|
250 |
+
result_word = "REAL"
|
251 |
+
if user_image is not None:
|
252 |
+
if len(predictions) > 0:
|
253 |
+
result_placeholder.markdown(f"<div class='result'> <span class = 'prediction'>Prediction: {scaled_prediction:.2%}</span> <br> It is a <span class = resultword> {result_word} </span> image. </div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
254 |
|
255 |
print(model_name)
|
256 |
print(predictions[0])
|