Tesneem commited on
Commit
ac447cb
1 Parent(s): 151ec6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
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 == 'CNN':
229
- print('CNN is running')
230
- predictions = pre_process_img(user_image)
231
- elif model_name == 'Efficientnet':
232
- print('Effnet is running')
233
- predictions = pre_process_img_effNet(user_image)
 
 
 
 
 
 
 
 
234
 
235
  elif model_name == 'Efficientnet Art':
236
  print('Effnet Art is running')
237
  predictions = pre_process_img_effNetArt(user_image)
238
- print(predictions)
239
-
240
-
241
- if predictions[0] < 0.5:
242
- result_word = "AI Generated"
243
- else:
244
- result_word = "REAL"
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])