has12zen commited on
Commit
3af08fb
·
1 Parent(s): b3eb5c0
Files changed (2) hide show
  1. app.py +1 -0
  2. utils.py +8 -1
app.py CHANGED
@@ -11,6 +11,7 @@ with gr.Blocks() as demo:
11
  encrypt_output = gr.Video(label="Mahalanobis distance")
12
  decrypt_output = gr.Textbox(lines=1, label="output")
13
  encrypt_button = gr.Button("Process")
 
14
 
15
  encrypt_button.click(final_main, inputs=[v1, v2 ], outputs=[encrypt_output,decrypt_output])
16
 
 
11
  encrypt_output = gr.Video(label="Mahalanobis distance")
12
  decrypt_output = gr.Textbox(lines=1, label="output")
13
  encrypt_button = gr.Button("Process")
14
+ gr.Markdown("It takes around 10min to process 10sec videos")
15
 
16
  encrypt_button.click(final_main, inputs=[v1, v2 ], outputs=[encrypt_output,decrypt_output])
17
 
utils.py CHANGED
@@ -188,12 +188,17 @@ def final_main(input1,input2):
188
  f1 = read_file(input1)
189
  of1 = read_file(input2)
190
  pf1 = process_video(f1)
 
191
  pof1=process_video(of1)
 
192
  fd1 = extract_video(pf1)
 
193
  ofd1 = extract_video(pof1)
 
194
  mean1,co_variance1,disc1,mean_1d_1,co_variance_1d_1,desc_1d_1=final(fd1)
195
  mean2,co_variance2,disc2,mean_1d_2,co_variance_1d_2,desc_1d_2=final(ofd1)
196
  distances = []
 
197
  for index,disc in enumerate(disc1):
198
  gm = disc - mean2
199
  dm = np.matmul(np.matmul(gm.T,np.linalg.inv(co_variance2)),gm)
@@ -216,7 +221,7 @@ def final_main(input1,input2):
216
  video = cv2.VideoWriter('video.mp4', fourcc, 30, (width,height))
217
  inital_diff,final_diff = 10000,-1
218
  result = ''
219
-
220
  for index, dist in enumerate(distances):
221
  heatmap = dist;
222
  frame,index = f1[index]
@@ -257,4 +262,6 @@ def final_main(input1,input2):
257
  outputString+=f"Initial difference at frame {inital_diff} at time {inital_diff/fps} seconds"
258
  outputString+=f"Final difference at frame {final_diff} at time {final_diff/fps} seconds"
259
  video.release()
 
 
260
  return ("video.mp4",outputString)
 
188
  f1 = read_file(input1)
189
  of1 = read_file(input2)
190
  pf1 = process_video(f1)
191
+ print("video1 processed residual and quantization")
192
  pof1=process_video(of1)
193
+ print("video2 processed residual and quantization")
194
  fd1 = extract_video(pf1)
195
+ print("video1 Created co-variance matrix")
196
  ofd1 = extract_video(pof1)
197
+ print("video2 Created co-variance matrix")
198
  mean1,co_variance1,disc1,mean_1d_1,co_variance_1d_1,desc_1d_1=final(fd1)
199
  mean2,co_variance2,disc2,mean_1d_2,co_variance_1d_2,desc_1d_2=final(ofd1)
200
  distances = []
201
+ print("creating Descriptors");
202
  for index,disc in enumerate(disc1):
203
  gm = disc - mean2
204
  dm = np.matmul(np.matmul(gm.T,np.linalg.inv(co_variance2)),gm)
 
221
  video = cv2.VideoWriter('video.mp4', fourcc, 30, (width,height))
222
  inital_diff,final_diff = 10000,-1
223
  result = ''
224
+ print("writing video")
225
  for index, dist in enumerate(distances):
226
  heatmap = dist;
227
  frame,index = f1[index]
 
262
  outputString+=f"Initial difference at frame {inital_diff} at time {inital_diff/fps} seconds"
263
  outputString+=f"Final difference at frame {final_diff} at time {final_diff/fps} seconds"
264
  video.release()
265
+ if(outputString==""):
266
+ outputString= "Not tampering are detected"
267
  return ("video.mp4",outputString)