dslee2601 commited on
Commit
5808c9b
·
1 Parent(s): 7e213c7

update notebook, adding a testing code

Browse files
Files changed (1) hide show
  1. save_model.ipynb +46 -3
save_model.ipynb CHANGED
@@ -101,10 +101,53 @@
101
  },
102
  {
103
  "cell_type": "code",
104
- "execution_count": null,
105
  "metadata": {},
106
- "outputs": [],
107
- "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  ],
110
  "metadata": {
 
101
  },
102
  {
103
  "cell_type": "code",
104
+ "execution_count": 5,
105
  "metadata": {},
106
+ "outputs": [
107
+ {
108
+ "name": "stderr",
109
+ "output_type": "stream",
110
+ "text": [
111
+ "A new version of the following files was downloaded from https://huggingface.co/hance-ai/descript-audio-codec:\n",
112
+ "- model.py\n",
113
+ ". Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.\n",
114
+ "C:\\Users\\dslee\\AppData\\Roaming\\Python\\Python38\\site-packages\\audiotools\\ml\\layers\\base.py:172: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
115
+ " model_dict = torch.load(location, \"cpu\")\n",
116
+ "c:\\Users\\dslee\\anaconda3\\envs\\sound_effect_variation_generation\\lib\\site-packages\\torch\\nn\\utils\\weight_norm.py:134: FutureWarning: `torch.nn.utils.weight_norm` is deprecated in favor of `torch.nn.utils.parametrizations.weight_norm`.\n",
117
+ " WeightNorm.apply(module, name, dim)\n"
118
+ ]
119
+ }
120
+ ],
121
+ "source": [
122
+ "# load the uploaded model\n",
123
+ "from transformers import AutoModel\n",
124
+ "model = AutoModel.from_pretrained('hance-ai/descript-audio-codec', trust_remote_code=True)"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "code",
129
+ "execution_count": 6,
130
+ "metadata": {},
131
+ "outputs": [
132
+ {
133
+ "name": "stdout",
134
+ "output_type": "stream",
135
+ "text": [
136
+ "zq.shape: torch.Size([1, 1024, 862])\n",
137
+ "s.shape: torch.Size([1, 9, 862])\n"
138
+ ]
139
+ }
140
+ ],
141
+ "source": [
142
+ "# encodeing\n",
143
+ "import os\n",
144
+ "from pathlib import Path\n",
145
+ "\n",
146
+ "fname = str(Path(os.getcwd()).joinpath('.sample_sound', 'jazz_swing.wav'))\n",
147
+ "zq, s = model.encode(fname)\n",
148
+ "print('zq.shape:', zq.shape)\n",
149
+ "print('s.shape:', s.shape)"
150
+ ]
151
  }
152
  ],
153
  "metadata": {