Skip to content

Commit ca6fc3b

Browse files
feat: Update conversion notebook to include task
1 parent 69089b1 commit ca6fc3b

File tree

1 file changed

+28
-55
lines changed

1 file changed

+28
-55
lines changed

scripts/convert_upload_hf.ipynb

+28-55
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"source": [
6-
"### Download and Install Dependencies"
7-
],
85
"metadata": {
96
"id": "fwxJqHJiiYHX"
10-
}
7+
},
8+
"source": [
9+
"### Download and Install Dependencies"
10+
]
1111
},
1212
{
1313
"cell_type": "code",
1414
"execution_count": null,
1515
"metadata": {
16+
"collapsed": true,
1617
"id": "_7D67c3Sc7Aa"
1718
},
1819
"outputs": [],
@@ -49,6 +50,7 @@
4950
"cell_type": "code",
5051
"execution_count": null,
5152
"metadata": {
53+
"collapsed": true,
5254
"id": "foOxhxatc7Ad"
5355
},
5456
"outputs": [],
@@ -79,6 +81,7 @@
7981
"outputs": [],
8082
"source": [
8183
"model = \"textattack/bert-base-uncased-rotten-tomatoes\" # @param {type:\"string\"}\n",
84+
"task = \"text-classification\" # @param {type:\"string\"}\n",
8285
"user = \"codewithkyrian\" # @param {type:\"string\"}"
8386
]
8487
},
@@ -96,42 +99,31 @@
9699
"cell_type": "code",
97100
"execution_count": null,
98101
"metadata": {
102+
"collapsed": true,
99103
"id": "AZgFlpvdc7Ae"
100104
},
101105
"outputs": [],
102106
"source": [
103107
"os.makedirs(\"models\", exist_ok=True)\n",
104-
"!python convert.py --quantize --model_id $model"
108+
"!python convert.py --quantize --model_id $model --task $task"
105109
]
106110
},
107111
{
108112
"cell_type": "markdown",
109-
"source": [
110-
"### Upload Converted model to 🤗 Hub"
111-
],
112113
"metadata": {
113114
"id": "sZ6Hna1xikyk"
114-
}
115+
},
116+
"source": [
117+
"### Upload Converted model to 🤗 Hub"
118+
]
115119
},
116120
{
117121
"cell_type": "code",
118122
"execution_count": null,
119123
"metadata": {
120-
"colab": {
121-
"base_uri": "https://localhost:8080/"
122-
},
123-
"id": "6TWHZV29c7Ae",
124-
"outputId": "06171614-95a7-48c1-822f-5cbbf20ec260"
125-
},
126-
"outputs": [
127-
{
128-
"output_type": "stream",
129-
"name": "stdout",
130-
"text": [
131-
"Repo ID: codewithkyrian/bert-base-uncased-rotten-tomatoes\n"
132-
]
133-
}
134-
],
124+
"id": "6TWHZV29c7Ae"
125+
},
126+
"outputs": [],
135127
"source": [
136128
"model_name = model.split(\"/\")[-1]\n",
137129
"repo_id = f\"{user}/{model_name}\" # new repo id with user\n",
@@ -178,6 +170,7 @@
178170
"card_meta['library_name'] = \"Transformers PHP\"\n",
179171
"card_meta.setdefault('tags', []) # sometimes, tags key doesn't exist\n",
180172
"card_meta['tags'] += [\"onnx\"]\n",
173+
"card_meta['pipeline_tag'] = task\n",
181174
"card_meta = ModelCardData(**card_meta)"
182175
]
183176
},
@@ -200,54 +193,34 @@
200193
"{card.text}\n",
201194
"---\n",
202195
"\n",
203-
"Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).\n",
196+
"Note: Having a separate repo for ONNX weights is intended to be a temporary solution until ONNXRuntime gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).\n",
204197
"\"\"\""
205198
]
206199
},
207200
{
208201
"cell_type": "code",
209202
"execution_count": null,
210203
"metadata": {
211-
"colab": {
212-
"base_uri": "https://localhost:8080/",
213-
"height": 69
214-
},
215-
"id": "t364cswtc7Af",
216-
"outputId": "1d4eef30-db03-4c71-baae-de17ee2adef7"
217-
},
218-
"outputs": [
219-
{
220-
"output_type": "execute_result",
221-
"data": {
222-
"text/plain": [
223-
"CommitInfo(commit_url='https://huggingface.co/codewithkyrian/bert-base-uncased-rotten-tomatoes/commit/2a2a5c72c5b6365ff17a01c4ec3330566fea3855', commit_message='Upload README.md with huggingface_hub', commit_description='', oid='2a2a5c72c5b6365ff17a01c4ec3330566fea3855', pr_url=None, pr_revision=None, pr_num=None)"
224-
],
225-
"application/vnd.google.colaboratory.intrinsic+json": {
226-
"type": "string"
227-
}
228-
},
229-
"metadata": {},
230-
"execution_count": 22
231-
}
232-
],
204+
"id": "t364cswtc7Af"
205+
},
206+
"outputs": [],
233207
"source": [
234208
"ModelCard(content).push_to_hub(repo_id) # push the new model card to the hub"
235209
]
236210
}
237211
],
238212
"metadata": {
239-
"language_info": {
240-
"name": "python"
241-
},
242213
"colab": {
243-
"provenance": [],
244-
"toc_visible": true
214+
"provenance": []
245215
},
246216
"kernelspec": {
247-
"name": "python3",
248-
"display_name": "Python 3"
217+
"display_name": "Python 3",
218+
"name": "python3"
219+
},
220+
"language_info": {
221+
"name": "python"
249222
}
250223
},
251224
"nbformat": 4,
252225
"nbformat_minor": 0
253-
}
226+
}

0 commit comments

Comments
 (0)