{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":91249,"databundleVersionId":11294684,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Since this is my first contest of this sort, I wanted to better understand the problem statement. Here's a neat ffmpeg command I was able to put together from various Stackoverflow posts to concatenate all the slides and visualize a tomogram :)\n\nMy understanding TL:DR; Given a tomogram (kind of like an MRI scan, takes a lot of cross sectional photos of bacteria as it moves through), identify if the given bacteria has a flagellar motor (tail-like thing they swim around with), and if it does, return the approximate position of that motor. It's considered a successful prediction if the distance in angstroms is < 1000. The pixel to pixel/slide to slide distance is on average 13-16 angstroms, can be seen in the train_labels.csv. No info of that distance translation is given for the test tomograms.\n\n---------------------------------------------------------------------------------------------------------------------\nYou can increase the constant rate factor, -crf, for faster generation, but the noise gets worse and worse. The size also exponentially decreases. \n\n- -crf 24 -> clear video (still as noisy as the images, but looks good), but 300Mb+\n- -crf 33 -> More noisy, but the bacterium and its flagellum still clearly visible, 22Mb\n- -crf 40 -> So noisy it hurts your brain, but the bacterium and its flagellum are still distinguishable, and only 400kB!!\n\nVideo below is with crf 33.","metadata":{}},{"cell_type":"code","source":"!ffmpeg -framerate 24 -pattern_type glob -i '/kaggle/input/byu-locating-bacterial-flagellar-motors-2025/test/tomo_00e047/*.jpg' -vf \"pad=ceil(iw/2)*2:ceil(ih/2)*2\"  -c:v libx264 -pix_fmt yuv420p -crf 33 '/kaggle/working/out.mp4'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-06T02:44:53.132065Z","iopub.execute_input":"2025-03-06T02:44:53.132422Z","iopub.status.idle":"2025-03-06T02:45:11.368795Z","shell.execute_reply.started":"2025-03-06T02:44:53.132393Z","shell.execute_reply":"2025-03-06T02:45:11.366862Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from IPython.display import Video\nVideo(\"/kaggle/working/out.mp4\", embed=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-06T02:45:11.371307Z","iopub.execute_input":"2025-03-06T02:45:11.371780Z","iopub.status.idle":"2025-03-06T02:45:12.052720Z","shell.execute_reply.started":"2025-03-06T02:45:11.371734Z","shell.execute_reply":"2025-03-06T02:45:12.051598Z"}},"outputs":[],"execution_count":null}]}