AI-RESEARCHER-2024 commited on
Commit
c658ee4
·
verified ·
1 Parent(s): 024209c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -103,7 +103,7 @@ def process_video(video_path, true_label=None):
103
  cnn_frame = cnn_frame.reshape(1, 28, 28, 1)
104
  # Predict with cnn_model
105
  cnn_pred = cnn_model.predict(cnn_frame)
106
- cnn_label = np.argmax(cnn_pred)
107
  if cnn_label == 0:
108
  cnn_class0 += 1
109
  else:
@@ -115,7 +115,7 @@ def process_video(video_path, true_label=None):
115
  q_frame = process_frame(frame)
116
  # Predict with qcnn_model
117
  qcnn_pred = qcnn_model.predict(q_frame)
118
- qcnn_label = np.argmax(qcnn_pred)
119
  if qcnn_label == 0:
120
  qcnn_class0 += 1
121
  else:
@@ -141,8 +141,8 @@ def process_video(video_path, true_label=None):
141
  result = f"CNN Model Accuracy: {cnn_accuracy:.2f}%\n"
142
  result += f"QCNN Model Accuracy: {qcnn_accuracy:.2f}%"
143
  else:
144
- result = f"CNN Model Predictions:\nOriginal: {cnn_class0_percent:.2f}%\nFake: {cnn_class1_percent:.2f}%\n"
145
- result += f"QCNN Model Predictions:\nOriginal: {qcnn_class0_percent:.2f}%\nFake: {qcnn_class1_percent:.2f}%"
146
  return result
147
 
148
  def predict(video_input):
@@ -192,7 +192,7 @@ with gr.Blocks() as demo:
192
  )
193
  with gr.Column():
194
  output = gr.Textbox(label="Result")
195
- predict_button = gr.Button("Predict")
196
 
197
  predict_button.click(fn=predict, inputs=video_input, outputs=output)
198
  demo.launch()
 
103
  cnn_frame = cnn_frame.reshape(1, 28, 28, 1)
104
  # Predict with cnn_model
105
  cnn_pred = cnn_model.predict(cnn_frame)
106
+ cnn_label = (cnn_pred > 0.5).astype(int)
107
  if cnn_label == 0:
108
  cnn_class0 += 1
109
  else:
 
115
  q_frame = process_frame(frame)
116
  # Predict with qcnn_model
117
  qcnn_pred = qcnn_model.predict(q_frame)
118
+ qcnn_label = (qcnn_pred > 0.5).astype(int)
119
  if qcnn_label == 0:
120
  qcnn_class0 += 1
121
  else:
 
141
  result = f"CNN Model Accuracy: {cnn_accuracy:.2f}%\n"
142
  result += f"QCNN Model Accuracy: {qcnn_accuracy:.2f}%"
143
  else:
144
+ result = f"CNN Model Predictions:\nClass 0: {cnn_class0_percent:.2f}%\nClass 1: {cnn_class1_percent:.2f}%\n"
145
+ result += f"QCNN Model Predictions:\nClass 0: {qcnn_class0_percent:.2f}%\nClass 1: {qcnn_class1_percent:.2f}%"
146
  return result
147
 
148
  def predict(video_input):
 
192
  )
193
  with gr.Column():
194
  output = gr.Textbox(label="Result")
195
+ predict_button = gr.Button("Predict", elem_classes="gr-button")
196
 
197
  predict_button.click(fn=predict, inputs=video_input, outputs=output)
198
  demo.launch()