Created
March 13, 2024 21:24
-
-
Save FurkanGozukara/84ad2cf9731c278d5679f7b5fcf5e44e to your computer and use it in GitHub Desktop.
upload_hugging_face.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "caa74bef", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"pip install huggingface_hub --upgrade" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "e10d4e70-b7c5-476b-916c-14cce7e436e5", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from huggingface_hub import login\n", | |
"login()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "0502703b-8b44-4e58-af2c-82f67d713548", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from huggingface_hub import HfApi\n", | |
"api = HfApi()\n", | |
"api.upload_file(\n", | |
" path_or_fileobj=r\"/home/Ubuntu/apps/stable-diffusion-webui/models/Stable-diffusion/model_name.safetensors\",\n", | |
" path_in_repo=\"model_name.safetensors\",\n", | |
" repo_id=\"YourUserName/reponame\",\n", | |
" repo_type=\"model\",\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "3be9367c-a04d-4d05-83ad-c8504e0383b4", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from huggingface_hub import HfApi\n", | |
"api = HfApi()\n", | |
"api.upload_folder(\n", | |
" folder_path=r\"/home/Ubuntu/apps/stable-diffusion-webui/models/Stable-diffusion\",\n", | |
" repo_id=\"YourUserName/reponame\",\n", | |
" repo_type=\"model\",\n", | |
")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "6fc96104", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from huggingface_hub import HfApi\n", | |
"from huggingface_hub import get_collection, delete_collection_item\n", | |
"from huggingface_hub import upload_file\n", | |
"from huggingface_hub import (\n", | |
" HfFolder,\n", | |
" ModelCard,\n", | |
" ModelCardData,\n", | |
" create_repo,\n", | |
" hf_hub_download,\n", | |
" upload_folder,\n", | |
" whoami,\n", | |
")\n", | |
"api = HfApi()\n", | |
"upload_folder(\n", | |
" folder_path=r\"/home/Ubuntu/apps/stable-diffusion-webui/models/Stable-diffusion\",\n", | |
" repo_id=\"YourUserName/reponame\",\n", | |
" repo_type=\"model\",\n", | |
" multi_commits=True,\n", | |
" multi_commits_verbose=True,\n", | |
")\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.9.16" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment