{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Full analysis: https://www.kaggle.com/code/robbynevels/identifying-duplicates-with-embeddings","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nfrom pathlib import Path","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:10:17.222624Z","iopub.execute_input":"2023-04-10T13:10:17.223592Z","iopub.status.idle":"2023-04-10T13:10:17.257536Z","shell.execute_reply.started":"2023-04-10T13:10:17.223544Z","shell.execute_reply":"2023-04-10T13:10:17.256385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/birdclef-2023/train_metadata.csv')\nTRAIN_PATH = Path('/kaggle/input/birdclef-2023/train_audio')","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:10:17.259743Z","iopub.execute_input":"2023-04-10T13:10:17.260241Z","iopub.status.idle":"2023-04-10T13:10:17.439287Z","shell.execute_reply.started":"2023-04-10T13:10:17.260197Z","shell.execute_reply":"2023-04-10T13:10:17.435897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# helpers for displaying bird recordings for manual inspection\n\nfrom IPython.display import Audio\nimport torchaudio\nimport matplotlib.pyplot as plt\n\nSAMPLE_RATE = 32_000\n\ncompute_melspec = torchaudio.transforms.MelSpectrogram(\n    sample_rate=SAMPLE_RATE,\n    n_mels=128,\n    n_fft=2048, \n    hop_length=512,\n    f_min=0,\n    f_max=SAMPLE_RATE // 2,\n)\n\npower_to_db = torchaudio.transforms.AmplitudeToDB(\n    stype=\"power\",\n    top_db=80.0,\n)\n\n\ndef show_bird(index, start=0, secs=5):\n    display(df.iloc[index])\n    audio = torchaudio.load(TRAIN_PATH / df.filename[index], start, start+32_000*secs)[0][0]\n    display(Audio(audio, rate=SAMPLE_RATE))\n    plt.figure(figsize=(12, 2.5))\n    plt.subplot(121)\n    plt.plot(audio)\n    plt.gca().get_xaxis().set_visible(False)\n    plt.subplot(122)\n    plt.imshow(power_to_db(compute_melspec(audio)))\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:11:20.015344Z","iopub.execute_input":"2023-04-10T13:11:20.015841Z","iopub.status.idle":"2023-04-10T13:11:20.030651Z","shell.execute_reply.started":"2023-04-10T13:11:20.015802Z","shell.execute_reply":"2023-04-10T13:11:20.029147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_bird(16073, secs=10)\nshow_bird(16049, secs=10)","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:11:20.680737Z","iopub.execute_input":"2023-04-10T13:11:20.681959Z","iopub.status.idle":"2023-04-10T13:11:31.273504Z","shell.execute_reply.started":"2023-04-10T13:11:20.681898Z","shell.execute_reply":"2023-04-10T13:11:31.269600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_bird(12077, secs=10)\nshow_bird(11896, secs=10)","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:11:31.276433Z","iopub.execute_input":"2023-04-10T13:11:31.276806Z","iopub.status.idle":"2023-04-10T13:11:40.922889Z","shell.execute_reply.started":"2023-04-10T13:11:31.276772Z","shell.execute_reply":"2023-04-10T13:11:40.921534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_bird(5569, secs=10)\nshow_bird(5570, secs=10)","metadata":{"execution":{"iopub.status.busy":"2023-04-10T13:11:40.924811Z","iopub.execute_input":"2023-04-10T13:11:40.926322Z","iopub.status.idle":"2023-04-10T13:11:51.053331Z","shell.execute_reply.started":"2023-04-10T13:11:40.926262Z","shell.execute_reply":"2023-04-10T13:11:51.052328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}