chainyo commited on
Commit
90c75b6
1 Parent(s): 8370452

fix test notebook

Browse files
Files changed (1) hide show
  1. finetuning.ipynb +41 -12
finetuning.ipynb CHANGED
@@ -940,7 +940,7 @@
940
  },
941
  {
942
  "cell_type": "code",
943
- "execution_count": 32,
944
  "metadata": {},
945
  "outputs": [
946
  {
@@ -951,21 +951,50 @@
951
  "remote: Enforcing permissions... \n",
952
  "remote: Allowed refs: all \n",
953
  "To https://huggingface.co/ChainYo/segformer-sidewalk\n",
954
- " 5d5f276..56db83f main -> main\n",
955
- "\n"
 
 
 
 
 
 
956
  ]
957
  },
958
  {
959
- "ename": "TypeError",
960
- "evalue": "__init__() got an unexpected keyword argument 'num_labels'",
961
- "output_type": "error",
962
- "traceback": [
963
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
964
- "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
965
- "\u001b[1;32m/home/chainyo/code/segformer-sidewalk/finetuning.ipynb Cell 23'\u001b[0m in \u001b[0;36m<cell line: 11>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=7'>8</a>\u001b[0m config \u001b[39m=\u001b[39m AutoConfig\u001b[39m.\u001b[39mfrom_pretrained(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mnvidia/mit-b0\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=8'>9</a>\u001b[0m config\u001b[39m.\u001b[39mpush_to_hub(\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m, repo_url\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mhttps://huggingface.co/ChainYo/segformer-sidewalk\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m---> <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=10'>11</a>\u001b[0m model \u001b[39m=\u001b[39m SegformerForSemanticSegmentation\u001b[39m.\u001b[39;49mfrom_pretrained(\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=11'>12</a>\u001b[0m \u001b[39m\"\u001b[39;49m\u001b[39m/home/chainyo/code/segformer-sidewalk/checkpoints/epoch=44-step=1125.ckpt\u001b[39;49m\u001b[39m\"\u001b[39;49m, \n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=12'>13</a>\u001b[0m num_labels\u001b[39m=\u001b[39;49mnum_labels, \n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=13'>14</a>\u001b[0m id2label\u001b[39m=\u001b[39;49mid2label, \n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=14'>15</a>\u001b[0m label2id\u001b[39m=\u001b[39;49mid2label,\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=15'>16</a>\u001b[0m config\u001b[39m=\u001b[39;49mconfig,\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=16'>17</a>\u001b[0m )\n\u001b[1;32m <a href='vscode-notebook-cell:/home/chainyo/code/segformer-sidewalk/finetuning.ipynb#ch0000016?line=17'>18</a>\u001b[0m model\u001b[39m.\u001b[39mpush_to_hub(\u001b[39m\"\u001b[39m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m, repo_url\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mhttps://huggingface.co/ChainYo/segformer-sidewalk\u001b[39m\u001b[39m\"\u001b[39m)\n",
966
- "File \u001b[0;32m~/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py:2024\u001b[0m, in \u001b[0;36mPreTrainedModel.from_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, *model_args, **kwargs)\u001b[0m\n\u001b[1;32m <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2021'>2022</a>\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2022'>2023</a>\u001b[0m \u001b[39mwith\u001b[39;00m no_init_weights(_enable\u001b[39m=\u001b[39m_fast_init):\n\u001b[0;32m-> <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2023'>2024</a>\u001b[0m model \u001b[39m=\u001b[39m \u001b[39mcls\u001b[39;49m(config, \u001b[39m*\u001b[39;49mmodel_args, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mmodel_kwargs)\n\u001b[1;32m <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2025'>2026</a>\u001b[0m \u001b[39mif\u001b[39;00m from_tf:\n\u001b[1;32m <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2026'>2027</a>\u001b[0m \u001b[39mif\u001b[39;00m resolved_archive_file\u001b[39m.\u001b[39mendswith(\u001b[39m\"\u001b[39m\u001b[39m.index\u001b[39m\u001b[39m\"\u001b[39m):\n\u001b[1;32m <a href='file:///home/chainyo/miniconda3/envs/segformer/lib/python3.8/site-packages/transformers/modeling_utils.py?line=2027'>2028</a>\u001b[0m \u001b[39m# Load from a TensorFlow 1.X checkpoint - provided by original authors\u001b[39;00m\n",
967
- "\u001b[0;31mTypeError\u001b[0m: __init__() got an unexpected keyword argument 'num_labels'"
 
 
 
 
 
 
 
 
 
 
 
 
 
968
  ]
 
 
 
 
 
 
 
 
 
 
969
  }
970
  ],
971
  "source": [
 
940
  },
941
  {
942
  "cell_type": "code",
943
+ "execution_count": 33,
944
  "metadata": {},
945
  "outputs": [
946
  {
 
951
  "remote: Enforcing permissions... \n",
952
  "remote: Allowed refs: all \n",
953
  "To https://huggingface.co/ChainYo/segformer-sidewalk\n",
954
+ " 56db83f..fcb528d main -> main\n",
955
+ "\n",
956
+ "Some weights of the model checkpoint at /home/chainyo/code/segformer-sidewalk/checkpoints/epoch=44-step=1125.ckpt were not used when initializing SegformerForSemanticSegmentation: ['pytorch-lightning_version', 'epoch', 'hyper_parameters', 'optimizer_states', 'loops', 'global_step', 'state_dict', 'callbacks', 'lr_schedulers', 'hparams_name']\n",
957
+ "- This IS expected if you are initializing SegformerForSemanticSegmentation from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
958
+ "- This IS NOT expected if you are initializing SegformerForSemanticSegmentation from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
959
+ "Some weights of SegformerForSemanticSegmentation were not initialized from the model checkpoint at /home/chainyo/code/segformer-sidewalk/checkpoints/epoch=44-step=1125.ckpt and are newly initialized: ['encoder.block.1.0.mlp.dwconv.dwconv.weight', 'encoder.block.1.0.layer_norm_2.bias', 'encoder.block.1.0.attention.output.dense.weight', 'encoder.block.0.0.mlp.dwconv.dwconv.bias', 'decode_head.batch_norm.running_var', 'decode_head.linear_c.1.proj.weight', 'encoder.block.1.0.mlp.dense1.weight', 'encoder.block.3.1.attention.self.value.weight', 'encoder.block.2.1.attention.output.dense.weight', 'encoder.block.3.1.mlp.dense1.bias', 'encoder.block.1.1.attention.self.sr.weight', 'encoder.block.2.1.attention.self.sr.bias', 'encoder.block.2.0.attention.self.value.weight', 'encoder.block.1.0.attention.self.sr.bias', 'encoder.block.2.0.layer_norm_2.bias', 'encoder.block.0.1.layer_norm_1.weight', 'encoder.patch_embeddings.2.proj.weight', 'encoder.block.0.1.layer_norm_2.weight', 'encoder.block.3.1.mlp.dwconv.dwconv.bias', 'encoder.block.2.1.layer_norm_2.weight', 'encoder.block.2.1.layer_norm_2.bias', 'encoder.block.3.0.layer_norm_1.bias', 'encoder.block.1.0.attention.self.layer_norm.bias', 'encoder.block.0.1.attention.self.sr.weight', 'encoder.block.2.0.attention.self.sr.weight', 'encoder.block.2.0.attention.self.layer_norm.bias', 'decode_head.classifier.weight', 'encoder.block.3.1.attention.self.query.weight', 'encoder.block.1.0.mlp.dense1.bias', 'encoder.block.0.0.layer_norm_1.bias', 'encoder.block.0.1.mlp.dense1.weight', 'encoder.block.2.0.layer_norm_1.weight', 'encoder.block.0.0.mlp.dense2.weight', 'encoder.block.1.0.layer_norm_2.weight', 'encoder.block.2.1.attention.output.dense.bias', 'encoder.block.0.0.attention.self.value.bias', 'encoder.block.3.0.attention.self.query.bias', 'encoder.block.1.1.attention.self.layer_norm.bias', 'decode_head.linear_c.2.proj.weight', 'encoder.block.3.0.mlp.dense1.weight', 'encoder.block.3.0.mlp.dense1.bias', 'encoder.patch_embeddings.1.layer_norm.bias', 'encoder.block.3.1.mlp.dense2.weight', 'encoder.block.1.0.mlp.dwconv.dwconv.bias', 'encoder.block.1.0.attention.self.query.weight', 'encoder.block.2.0.attention.self.query.bias', 'encoder.block.3.0.attention.output.dense.bias', 'encoder.block.2.1.attention.self.sr.weight', 'decode_head.batch_norm.running_mean', 'encoder.block.3.0.attention.self.key.weight', 'encoder.block.0.1.attention.self.layer_norm.bias', 'encoder.block.0.0.attention.self.sr.bias', 'encoder.block.3.1.layer_norm_1.bias', 'encoder.block.0.1.attention.self.value.bias', 'encoder.block.0.1.attention.self.sr.bias', 'encoder.block.0.1.attention.self.key.weight', 'encoder.block.1.0.attention.self.value.bias', 'encoder.block.0.0.attention.self.layer_norm.weight', 'encoder.patch_embeddings.0.layer_norm.bias', 'encoder.patch_embeddings.3.proj.bias', 'encoder.block.1.1.attention.self.key.weight', 'encoder.block.1.1.attention.self.sr.bias', 'encoder.block.2.0.attention.self.key.weight', 'decode_head.linear_fuse.weight', 'encoder.block.0.1.mlp.dwconv.dwconv.bias', 'encoder.block.0.1.attention.self.layer_norm.weight', 'encoder.block.0.1.mlp.dwconv.dwconv.weight', 'encoder.block.2.0.layer_norm_1.bias', 'encoder.block.0.0.attention.self.query.bias', 'encoder.block.3.1.attention.self.key.bias', 'encoder.block.3.0.mlp.dwconv.dwconv.weight', 'encoder.block.0.0.attention.self.layer_norm.bias', 'encoder.block.0.0.layer_norm_1.weight', 'encoder.block.1.1.mlp.dense2.bias', 'encoder.block.3.1.layer_norm_2.weight', 'encoder.block.3.0.attention.output.dense.weight', 'encoder.block.1.0.layer_norm_1.weight', 'encoder.block.2.0.attention.self.layer_norm.weight', 'encoder.block.2.1.attention.self.layer_norm.weight', 'encoder.block.0.0.layer_norm_2.weight', 'encoder.patch_embeddings.1.layer_norm.weight', 'encoder.block.2.1.mlp.dwconv.dwconv.weight', 'encoder.block.3.1.attention.output.dense.bias', 'encoder.block.1.1.attention.self.query.weight', 'encoder.block.1.0.attention.self.key.bias', 'encoder.block.0.1.attention.self.value.weight', 'encoder.patch_embeddings.1.proj.weight', 'encoder.block.1.1.layer_norm_1.bias', 'encoder.block.1.1.attention.self.value.weight', 'encoder.block.3.0.mlp.dense2.weight', 'encoder.block.1.0.attention.self.value.weight', 'decode_head.classifier.bias', 'encoder.block.2.0.mlp.dwconv.dwconv.bias', 'encoder.block.1.1.attention.output.dense.weight', 'encoder.block.2.1.attention.self.query.weight', 'decode_head.batch_norm.num_batches_tracked', 'encoder.patch_embeddings.0.layer_norm.weight', 'decode_head.linear_c.3.proj.bias', 'encoder.block.0.1.attention.output.dense.bias', 'encoder.block.1.1.mlp.dwconv.dwconv.weight', 'encoder.block.2.1.attention.self.layer_norm.bias', 'encoder.block.2.1.mlp.dwconv.dwconv.bias', 'encoder.layer_norm.0.bias', 'encoder.patch_embeddings.3.layer_norm.weight', 'encoder.block.0.1.mlp.dense1.bias', 'encoder.block.1.1.mlp.dense2.weight', 'decode_head.batch_norm.weight', 'encoder.block.3.1.attention.self.query.bias', 'encoder.block.0.0.attention.output.dense.weight', 'encoder.block.1.1.layer_norm_1.weight', 'encoder.layer_norm.1.weight', 'encoder.block.3.0.mlp.dense2.bias', 'encoder.layer_norm.3.bias', 'encoder.block.0.0.mlp.dwconv.dwconv.weight', 'encoder.block.1.1.attention.output.dense.bias', 'encoder.block.2.1.layer_norm_1.weight', 'encoder.block.1.1.attention.self.layer_norm.weight', 'encoder.block.1.1.attention.self.key.bias', 'encoder.block.2.0.attention.self.value.bias', 'encoder.block.0.0.attention.self.key.bias', 'encoder.block.2.1.attention.self.key.bias', 'encoder.block.0.0.layer_norm_2.bias', 'encoder.block.1.1.layer_norm_2.weight', 'encoder.layer_norm.2.weight', 'decode_head.linear_c.0.proj.weight', 'encoder.block.1.0.attention.self.sr.weight', 'encoder.block.1.0.mlp.dense2.weight', 'encoder.block.2.0.mlp.dense1.weight', 'encoder.block.3.0.layer_norm_1.weight', 'encoder.patch_embeddings.1.proj.bias', 'decode_head.linear_c.3.proj.weight', 'encoder.block.1.1.mlp.dwconv.dwconv.bias', 'decode_head.linear_c.1.proj.bias', 'encoder.block.2.1.mlp.dense2.bias', 'encoder.patch_embeddings.3.layer_norm.bias', 'encoder.block.0.0.mlp.dense2.bias', 'encoder.block.3.1.layer_norm_2.bias', 'encoder.block.1.0.attention.output.dense.bias', 'encoder.patch_embeddings.0.proj.bias', 'encoder.block.2.1.attention.self.query.bias', 'encoder.block.2.1.mlp.dense1.bias', 'encoder.block.3.1.mlp.dwconv.dwconv.weight', 'encoder.block.0.1.layer_norm_2.bias', 'encoder.block.3.1.mlp.dense1.weight', 'encoder.block.1.0.attention.self.key.weight', 'encoder.block.1.1.mlp.dense1.weight', 'encoder.block.0.1.mlp.dense2.bias', 'encoder.block.0.1.attention.self.query.weight', 'encoder.block.2.0.attention.self.sr.bias', 'encoder.block.2.0.attention.output.dense.bias', 'encoder.block.2.1.mlp.dense1.weight', 'encoder.block.2.1.attention.self.value.bias', 'encoder.block.0.0.attention.self.key.weight', 'encoder.block.2.0.attention.self.key.bias', 'encoder.block.2.1.mlp.dense2.weight', 'decode_head.linear_c.0.proj.bias', 'encoder.block.3.1.attention.self.value.bias', 'encoder.block.0.1.attention.self.query.bias', 'encoder.block.3.0.attention.self.key.bias', 'encoder.patch_embeddings.2.proj.bias', 'encoder.layer_norm.1.bias', 'encoder.block.2.0.attention.self.query.weight', 'encoder.layer_norm.0.weight', 'encoder.block.0.0.attention.self.query.weight', 'encoder.block.0.1.attention.output.dense.weight', 'encoder.block.1.0.attention.self.query.bias', 'encoder.block.2.1.attention.self.key.weight', 'encoder.block.1.0.attention.self.layer_norm.weight', 'encoder.block.3.0.layer_norm_2.weight', 'encoder.block.0.0.attention.self.value.weight', 'encoder.block.0.0.mlp.dense1.bias', 'encoder.block.2.0.layer_norm_2.weight', 'encoder.patch_embeddings.3.proj.weight', 'encoder.block.1.0.mlp.dense2.bias', 'encoder.block.1.1.mlp.dense1.bias', 'encoder.block.3.1.attention.output.dense.weight', 'encoder.block.0.1.layer_norm_1.bias', 'encoder.block.0.0.attention.output.dense.bias', 'encoder.block.3.1.layer_norm_1.weight', 'decode_head.batch_norm.bias', 'encoder.block.2.0.mlp.dwconv.dwconv.weight', 'encoder.block.3.0.mlp.dwconv.dwconv.bias', 'encoder.block.2.1.layer_norm_1.bias', 'encoder.patch_embeddings.2.layer_norm.weight', 'encoder.block.2.0.mlp.dense1.bias', 'encoder.block.3.1.attention.self.key.weight', 'encoder.block.0.0.mlp.dense1.weight', 'encoder.block.1.1.attention.self.query.bias', 'encoder.block.3.0.attention.self.query.weight', 'decode_head.linear_c.2.proj.bias', 'encoder.layer_norm.2.bias', 'encoder.block.0.0.attention.self.sr.weight', 'encoder.block.3.0.layer_norm_2.bias', 'encoder.block.1.0.layer_norm_1.bias', 'encoder.layer_norm.3.weight', 'encoder.block.0.1.mlp.dense2.weight', 'encoder.block.2.0.mlp.dense2.weight', 'encoder.block.0.1.attention.self.key.bias', 'encoder.block.1.1.attention.self.value.bias', 'encoder.block.2.1.attention.self.value.weight', 'encoder.block.1.1.layer_norm_2.bias', 'encoder.block.3.0.attention.self.value.bias', 'encoder.patch_embeddings.2.layer_norm.bias', 'encoder.block.2.0.attention.output.dense.weight', 'encoder.block.3.1.mlp.dense2.bias', 'encoder.block.3.0.attention.self.value.weight', 'encoder.patch_embeddings.0.proj.weight', 'encoder.block.2.0.mlp.dense2.bias']\n",
960
+ "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
961
+ "/home/chainyo/code/segformer-sidewalk/. is already a clone of https://huggingface.co/ChainYo/segformer-sidewalk. Make sure you pull the latest changes with `repo.git_pull()`.\n"
962
  ]
963
  },
964
  {
965
+ "data": {
966
+ "application/vnd.jupyter.widget-view+json": {
967
+ "model_id": "99e53578044149a1ac2cb3a53bc93015",
968
+ "version_major": 2,
969
+ "version_minor": 0
970
+ },
971
+ "text/plain": [
972
+ "Upload file pytorch_model.bin: 0%| | 32.0k/14.3M [00:00<?, ?B/s]"
973
+ ]
974
+ },
975
+ "metadata": {},
976
+ "output_type": "display_data"
977
+ },
978
+ {
979
+ "name": "stderr",
980
+ "output_type": "stream",
981
+ "text": [
982
+ "remote: Enforcing permissions... \n",
983
+ "remote: Allowed refs: all \n",
984
+ "To https://huggingface.co/ChainYo/segformer-sidewalk\n",
985
+ " fcb528d..8370452 main -> main\n",
986
+ "\n"
987
  ]
988
+ },
989
+ {
990
+ "data": {
991
+ "text/plain": [
992
+ "'https://huggingface.co/ChainYo/segformer-sidewalk/commit/83704520224204a5932e7a7e174051010a99fe83'"
993
+ ]
994
+ },
995
+ "execution_count": 33,
996
+ "metadata": {},
997
+ "output_type": "execute_result"
998
  }
999
  ],
1000
  "source": [