| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "8cfa8aa6-d276-417e-8903-10887f6aebca", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import huggingface_hub as hub" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 34, | |
| "id": "31c61098-c6ee-4466-a2e5-60337589367a", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "CEBAB = 'CEBaB'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "f9f929bc-5e76-445a-8e7d-43d4656c9583", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "cebab_models = hub.list_models(filter=hub.ModelFilter(author=CEBAB))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "id": "0cd3bf15-58a4-4485-ac0b-b941748c6d12", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "causalm_models = sorted([m.id for m in cebab_models if 'causalm' in m.id])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 25, | |
| "id": "c608e3ba-52fa-4fbf-aa07-1158938a8596", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "bert_causalm = [m for m in causalm_models if 'bert-base-uncased' in m and '__' in m]\n", | |
| "roberta_causalm = [m for m in causalm_models if 'roberta-base' in m]\n", | |
| "lstm_causalm = [m for m in causalm_models if 'lstm' in m]\n", | |
| "gpt2_causalm = [m for m in causalm_models if 'gpt2' in m]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 36, | |
| "id": "67ce63fc-87d7-4024-9b6e-9430b7be54c7", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "application/vnd.jupyter.widget-view+json": { | |
| "model_id": "a02948a164c74b80960a27911cd4a53a", | |
| "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": [ | |
| "hub.notebook_login()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 37, | |
| "id": "b0ad94fd-39d6-4490-bf41-a1591811b1cc", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stderr", | |
| "output_type": "stream", | |
| "text": [ | |
| "C:\\Users\\Eldar-P14s\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py:79: FutureWarning: `name` and `organization` input arguments are deprecated and will be removed in v0.7. Pass `repo_id` instead.\n", | |
| " warnings.warn(\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "repo_path = hub.create_repo(\n", | |
| " organization=CEBAB,\n", | |
| " name=f'eldar-try',\n", | |
| " exist_ok=True\n", | |
| ")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 43, | |
| "id": "aa49404b-79a6-4ba5-b31c-1971fb7320bd", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "ename": "HTTPError", | |
| "evalue": "500 Server Error: Internal Server Error for url: https://huggingface.co/api/CEBaB/eldar-try/upload/main/", | |
| "output_type": "error", | |
| "traceback": [ | |
| "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
| "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", | |
| "\u001b[1;32m<ipython-input-43-b4c91946ae88>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m hub.upload_file(\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mpath_or_fileobj\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'hub.ipynb'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mrepo_id\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'CEBaB/eldar-try'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mpath_in_repo\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m )\n", | |
| "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\utils\\_deprecation.py\u001b[0m in \u001b[0;36minner_f\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[0mextra_args\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mall_args\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mextra_args\u001b[0m \u001b[1;33m<=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 32\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 33\u001b[0m \u001b[1;31m# extra_args > 0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 34\u001b[0m args_msg = [\n", | |
| "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py\u001b[0m in \u001b[0;36mupload_file\u001b[1;34m(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, identical_ok)\u001b[0m\n\u001b[0;32m 1864\u001b[0m )\n\u001b[0;32m 1865\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1866\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1867\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1868\u001b[0m \u001b[0md\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
| "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py\u001b[0m in \u001b[0;36mupload_file\u001b[1;34m(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, identical_ok)\u001b[0m\n\u001b[0;32m 1855\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1856\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1857\u001b[1;33m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraise_for_status\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1858\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mHTTPError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1859\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0midentical_ok\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstatus_code\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m409\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
| "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mraise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 941\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 942\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mhttp_error_msg\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 943\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mHTTPError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhttp_error_msg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mresponse\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 944\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 945\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mclose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
| "\u001b[1;31mHTTPError\u001b[0m: 500 Server Error: Internal Server Error for url: https://huggingface.co/api/CEBaB/eldar-try/upload/main/" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "hub.upload_file(\n", | |
| " path_or_fileobj=\"hub.ipynb\",\n", | |
| " path_in_repo=\"\",\n", | |
| " repo_id=\"username/my-model\",\n", | |
| " token=\"my_token\",\n", | |
| ")" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "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.8.8" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } | |