{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4991385a-1cc9-4cd7-b144-36dc0478fafe", "metadata": {}, "outputs": [], "source": [ "#!pip install renumics-spotlight datasets[audio]" ] }, { "cell_type": "code", "execution_count": 2, "id": "a32c61a3-b0f8-430b-9c4d-ff27a1a7942e", "metadata": {}, "outputs": [], "source": [ "import datasets\n", "from renumics import spotlight" ] }, { "cell_type": "code", "execution_count": 3, "id": "fada8bfa-c2ea-441a-9d07-f67fa8047138", "metadata": {}, "outputs": [], "source": [ "dataset = datasets.load_dataset(\"renumics/speech_commands_enrichment_only\")\n", "raw_dataset = datasets.load_dataset(\"speech_commands\", 'v0.01')" ] }, { "cell_type": "code", "execution_count": 4, "id": "7e486382-31cd-4b69-8a9e-fe3d7ac94b41", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DatasetDict({\n", " train: Dataset({\n", " features: ['label_string', 'probability', 'probability_vector', 'prediction', 'prediction_string', 'embedding_reduced', '__index_level_0__'],\n", " num_rows: 51093\n", " })\n", " validation: Dataset({\n", " features: ['label_string', 'probability', 'probability_vector', 'prediction', 'prediction_string', 'embedding_reduced', '__index_level_0__'],\n", " num_rows: 6799\n", " })\n", " test: Dataset({\n", " features: ['label_string', 'probability', 'probability_vector', 'prediction', 'prediction_string', 'embedding_reduced', '__index_level_0__'],\n", " num_rows: 3081\n", " })\n", "})" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset" ] }, { "cell_type": "code", "execution_count": 5, "id": "9594c54a-c024-4492-af7b-f1c25bb4de6b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DatasetDict({\n", " train: Dataset({\n", " features: ['file', 'audio', 'label', 'is_unknown', 'speaker_id', 'utterance_id'],\n", " num_rows: 51093\n", " })\n", " validation: Dataset({\n", " features: ['file', 'audio', 'label', 'is_unknown', 'speaker_id', 'utterance_id'],\n", " num_rows: 6799\n", " })\n", " test: Dataset({\n", " features: ['file', 'audio', 'label', 'is_unknown', 'speaker_id', 'utterance_id'],\n", " num_rows: 3081\n", " })\n", "})" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raw_dataset" ] }, { "cell_type": "code", "execution_count": 6, "id": "ddda31eb-fdab-4ed3-81cc-88506ae0d7d5", "metadata": {}, "outputs": [], "source": [ "joined_dataset_enrichment = datasets.concatenate_datasets([dataset[\"train\"], dataset[\"validation\"], dataset[\"test\"]])\n", "raw_dataset_joined = datasets.concatenate_datasets([raw_dataset[\"train\"].sort(\"file\"), raw_dataset[\"validation\"].sort(\"file\"), \n", " raw_dataset[\"test\"].sort(\"file\")])" ] }, { "cell_type": "code", "execution_count": 7, "id": "2b8918a3-5037-4062-b9cd-40b4a8a4d6c0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['label_string', 'probability', 'probability_vector', 'prediction', 'prediction_string', 'embedding_reduced', '__index_level_0__'],\n", " num_rows: 60973\n", "})" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "joined_dataset_enrichment" ] }, { "cell_type": "code", "execution_count": 8, "id": "fa6ca118-3df0-4b6b-a036-4c70544500e3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['file', 'audio', 'label', 'is_unknown', 'speaker_id', 'utterance_id'],\n", " num_rows: 60973\n", "})" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#raw_dataset_joined = raw_dataset_joined.sort(\"file\")\n", "raw_dataset_joined" ] }, { "cell_type": "code", "execution_count": 9, "id": "0a56d781-5b5c-4deb-aa4f-c9a1a96ac650", "metadata": {}, "outputs": [], "source": [ "complete_dataset = datasets.concatenate_datasets([raw_dataset_joined, joined_dataset_enrichment], axis=1)" ] }, { "cell_type": "code", "execution_count": 10, "id": "cb487431-8bc6-483a-bf25-a917278b6781", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset({\n", " features: ['file', 'audio', 'label', 'is_unknown', 'speaker_id', 'utterance_id', 'label_string', 'probability', 'probability_vector', 'prediction', 'prediction_string', 'embedding_reduced', '__index_level_0__'],\n", " num_rows: 60973\n", "})" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "complete_dataset" ] }, { "cell_type": "code", "execution_count": 13, "id": "a11fefeb-9fd1-4500-9b9f-3275207b1cde", "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "'module' object is not callable", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[13], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m spotlight\u001b[38;5;241m.\u001b[39mshow(\n\u001b[1;32m 2\u001b[0m complete_dataset,\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m#layout= layout.parse(\"spotlight-layout.json\"),\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m layout\u001b[38;5;241m=\u001b[39m\u001b[43mspotlight\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlayouts\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel_debug\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m,\n\u001b[1;32m 5\u001b[0m port\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m7860\u001b[39m, \n\u001b[1;32m 6\u001b[0m host\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m0.0.0.0\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 7\u001b[0m allow_filebrowsing\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m \n\u001b[1;32m 8\u001b[0m )\n", "\u001b[0;31mTypeError\u001b[0m: 'module' object is not callable" ] } ], "source": [ "spotlight.show(\n", " complete_dataset,\n", " #layout= layout.parse(\"spotlight-layout.json\"),\n", " layout=spotlight.layouts.debug_classification(),\n", " port=7860, \n", " host=\"0.0.0.0\",\n", " allow_filebrowsing=False \n", " )" ] }, { "cell_type": "code", "execution_count": null, "id": "f1e38449-7bc1-4ae5-a754-a914a808a534", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }