YEHTUT commited on
Commit
d89de93
1 Parent(s): 161120c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -79,9 +79,7 @@ def predict2(image_np):
79
 
80
  return result_pil_img
81
  def write_video(video_in_filepath, video_out_filepath, detection_model):
82
- if not os.path.exists(video_in_filepath):
83
- print('video filepath not valid')
84
-
85
  video_reader = cv2.VideoCapture(video_in_filepath)
86
 
87
  nb_frames = int(video_reader.get(cv2.CAP_PROP_FRAME_COUNT))
@@ -117,6 +115,11 @@ def write_video(video_in_filepath, video_out_filepath, detection_model):
117
  video_writer.release()
118
  cv2.destroyAllWindows()
119
  cv2.waitKey(1)
 
 
 
 
 
120
 
121
  REPO_ID = "YEHTUT/tfodmodel"
122
  detection_model = load_model()
@@ -129,7 +132,7 @@ Image_tab = Interface(fn=predict,
129
  inputs=gr.Image(type="pil"),
130
  outputs=gr.Image(type="pil")
131
  )
132
- Video_tab = Interface(fn=predict,
133
  inputs=gr.Video,
134
  outputs=gr.Video
135
  )
 
79
 
80
  return result_pil_img
81
  def write_video(video_in_filepath, video_out_filepath, detection_model):
82
+
 
 
83
  video_reader = cv2.VideoCapture(video_in_filepath)
84
 
85
  nb_frames = int(video_reader.get(cv2.CAP_PROP_FRAME_COUNT))
 
115
  video_writer.release()
116
  cv2.destroyAllWindows()
117
  cv2.waitKey(1)
118
+
119
+ def predict_video (video_file_name):
120
+ detected_video_file = "detected_video.mp4"
121
+ write_video(video_file_name,detected_video_file,detection_model)
122
+ return detected_video_file
123
 
124
  REPO_ID = "YEHTUT/tfodmodel"
125
  detection_model = load_model()
 
132
  inputs=gr.Image(type="pil"),
133
  outputs=gr.Image(type="pil")
134
  )
135
+ Video_tab = Interface(fn=predict_video,
136
  inputs=gr.Video,
137
  outputs=gr.Video
138
  )