Spaces:
Sleeping
Sleeping
File size: 4,038 Bytes
7e6964a 75a65be 7e6964a 2e3bc39 7e6964a 75a65be 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a 2e3bc39 7e6964a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c0d9dc18aadb485086f5153f9b137368",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from huggingface_hub import notebook_login\n",
"\n",
"notebook_login()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"final_model\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/betty/miniconda3/envs/DP/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
" warnings.warn(\n"
]
}
],
"source": [
"from website_script import load\n",
"tokenizer, model, gazetteers_for_matching = load()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9e98fea6c2e440f29afb00c0ed5fedff",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"pytorch_model.bin: 0%| | 0.00/502M [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"CommitInfo(commit_url='https://huggingface.co/bettystr/NerRoB-czech/commit/0e6b09c5455288a3305b32e39626d89f7b3937dc', commit_message='Upload ExtendedEmbeddigsRobertaForTokenClassification', commit_description='', oid='0e6b09c5455288a3305b32e39626d89f7b3937dc', pr_url=None, pr_revision=None, pr_num=None)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.push_to_hub(\"bettystr/NerRoB-czech\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data from gazetteers.json has been loaded and saved as a pickle file at gazetteers.pkl.\n"
]
}
],
"source": [
"import json\n",
"import pickle\n",
"def load_json_as_pickle(json_path, pickle_path):\n",
" \"\"\"\n",
" Load data from a JSON file and save it as a pickle file.\n",
"\n",
" Parameters:\n",
" json_path (str): Path to the JSON file.\n",
" pickle_path (str): Path where the pickle file will be saved.\n",
" \"\"\"\n",
" # Load data from the JSON file\n",
" with open(json_path, 'r') as file:\n",
" data = json.load(file)\n",
" \n",
" # Save data to a pickle file\n",
" with open(pickle_path, 'wb') as file:\n",
" pickle.dump(data, file)\n",
"\n",
" print(f\"Data from {json_path} has been loaded and saved as a pickle file at {pickle_path}.\")\n",
"\n",
"# Example usage\n",
"json_path = 'gazetteers.json'\n",
"pickle_path = 'gazetteers.pkl'\n",
"load_json_as_pickle(json_path, pickle_path)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "DP",
"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.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|