Update app.py
Browse files52 unmodified lines53545556575859606162305 unmodified lines36836937037137237312 unmodified lines386387388389390391196 unmodified lines58858959059152 unmodified linescap.release()output_frames = int(total_frames * scale_slider)frame_interval = max(1, total_frames // output_frames)ffmpeg.input(input_video, hwaccel='cuda').output(os.path.join(output_dir, '%07d.jpg'), q=2, start_number=0,vf=rf'select=not(mod(n\,{frame_interval}))', vsync='vfr').run()first_frame_path = os.path.join(output_dir, '0000000.jpg')first_frame = cv2.imread(first_frame_path)305 unmodified lines<a href="https://drive.google.com/drive/folders/1EXzRkxZmrXbahCFA8_ImFRM6wQDEpOSe?usp=sharing"><img src="https://img.shields.io/badge/Video-Tutorial-green?style=plastic" alt="Video Tutorial" style="display:inline-block; margin-right:10px;"></a></div><div style="text-align:left; margin-bottom:20px;">This API supports using box (generated by scribble) and point prompts for video segmentation with12 unmodified lines<li>8. Download the video with segmentation results</li></ol></div>''')196 unmodified linesapp.launch(debug=True, enable_queue=True, share=False)if __name__ == "__main__":seg_track_app()52 unmodified lines535455565758596061626364656667686970305 unmodified lines37637737837938038138238338412 unmodified lines397398399400401402403404405406407196 unmodified lines60460560660752 unmodified linescap.release()output_frames = int(total_frames * scale_slider)frame_interval = max(1, total_frames // output_frames)print(f"frame_interval: {frame_interval}")try:ffmpeg.input(input_video, hwaccel='cuda').output(os.path.join(output_dir, '%07d.jpg'), q=2, start_number=0,vf=rf'select=not(mod(n\,{frame_interval}))', fps_mode='vfr').run()except:print(f"ffmpeg cuda err")ffmpeg.input(input_video).output(os.path.join(output_dir, '%07d.jpg'), q=2, start_number=0,vf=rf'select=not(mod(n\,{frame_interval}))', fps_mode='vfr').run()first_frame_path = os.path.join(output_dir, '0000000.jpg')first_frame = cv2.imread(first_frame_path)305 unmodified lines<a href="https://drive.google.com/drive/folders/1EXzRkxZmrXbahCFA8_ImFRM6wQDEpOSe?usp=sharing"><img src="https://img.shields.io/badge/Video-Tutorial-green?style=plastic" alt="Video Tutorial" style="display:inline-block; margin-right:10px;"></a><a href="https://github.com/bowang-lab/MedSAM/tree/MedSAM2?tab=readme-ov-file#fine-tune-sam2-on-the-abdomen-ct-dataset"><img src="https://img.shields.io/badge/Fine--tune-SAM2-blue" alt="Fine-tune SAM2" style="display:inline-block; margin-right:10px;"></a></div><div style="text-align:left; margin-bottom:20px;">This API supports using box (generated by scribble) and point prompts for video segmentation with12 unmodified lines<li>8. Download the video with segmentation results</li></ol></div><div style="text-align:left; margin-bottom:20px;">Other useful resources:<a href="https://ai.meta.com/sam2" target="_blank">Official demo</a> from MetaAI,<a href="https://www.youtube.com/watch?v=Dv003fTyO-Y" target="_blank">Video tutorial</a> from Piotr Skalski.</div>''')196 unmodified linesapp.launch(debug=True, enable_queue=True, share=False)if __name__ == "__main__":seg_track_app()
app.py+21-5