mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +03:00
Added Scuffed weights.gg model import (only works with model upload to huggingface)
This commit is contained in:
parent
f36138d64e
commit
df49eac1da
@ -148,9 +148,16 @@
|
||||
"# Install dependencies that are missing from requirements.txt and pyngrok\n",
|
||||
"!pip install faiss-gpu fairseq pyngrok --quiet\n",
|
||||
"!pip install pyworld --no-build-isolation --quiet\n",
|
||||
"# Install webstuff\n",
|
||||
"import asyncio\n",
|
||||
"import re\n",
|
||||
"!pip install playwright\n",
|
||||
"!playwright install\n",
|
||||
"!playwright install-deps\n",
|
||||
"from playwright.async_api import async_playwright\n",
|
||||
"print(f\"{Fore.CYAN}> Installing dependencies from requirements.txt...{Style.RESET_ALL}\")\n",
|
||||
"!pip install -r requirements.txt --quiet\n",
|
||||
"\n",
|
||||
"clear_output()\n",
|
||||
"print(f\"{Fore.GREEN}> Successfully installed all packages!{Style.RESET_ALL}\")"
|
||||
]
|
||||
},
|
||||
@ -168,12 +175,57 @@
|
||||
"\n",
|
||||
"!rm -rf model_dir/$model_slot\n",
|
||||
"#@markdown **[Optional]** Add an icon to the model\n",
|
||||
"icon_link = \"https://static.wikia.nocookie.net/virtualyoutuber/images/8/8b/ShyreiProfile.png\" #@param {type:\"string\"}\n",
|
||||
"icon_link = \"https://static.wikia.nocookie.net/youtube/images/c/ca/Shirahiko.jpg/revision/latest/scale-to-width-down/350?cb=20220903105322\" #@param {type:\"string\"}\n",
|
||||
"icon_link = '\"'+icon_link+'\"'\n",
|
||||
"!mkdir model_dir\n",
|
||||
"!mkdir model_dir/$model_slot\n",
|
||||
"#@markdown Put your model's download link here `(must be a zip file)`\n",
|
||||
"model_link = \"https://huggingface.co/RavenCutie21/Models/resolve/main/SquChan_e800_20800steps.zip?download=true\" #@param {type:\"string\"}\n",
|
||||
"#@markdown Put your model's download link here `(must be a zip file)` only supports **weights.gg** & **huggingface.co**\n",
|
||||
"model_link = \"https://www.weights.gg/models/clnk7yvvl009pwsbju6f8cldc\" #@param {type:\"string\"}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if model_link.startswith(\"https://www.weights.gg\") or model_link.startswith(\"https://weights.gg\"):\n",
|
||||
" async def get_weight_url(url):\n",
|
||||
" async with async_playwright() as p:\n",
|
||||
" browser = await p.firefox.launch()\n",
|
||||
" context = await browser.new_context()\n",
|
||||
" page = await context.new_page()\n",
|
||||
"\n",
|
||||
" try:\n",
|
||||
" # Navigate to the URL\n",
|
||||
" await page.goto(url)\n",
|
||||
"\n",
|
||||
" # Extract the content of the first meta tag with name='description'\n",
|
||||
" meta_content = await page.evaluate(\n",
|
||||
" '() => document.querySelector(\"meta[name=\\'description\\']\").getAttribute(\"content\")'\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" # Find the URL with the pattern \"https://huggingface.co/\"\n",
|
||||
" url_start_index = meta_content.find('https://huggingface.co/')\n",
|
||||
" if url_start_index != -1:\n",
|
||||
" # Extract the URL\n",
|
||||
" weight_url = meta_content[url_start_index:].split(' ')[0]\n",
|
||||
"\n",
|
||||
" # Remove \"<\" and \">\" characters from the URL\n",
|
||||
" cleaned_url = re.sub(r'[<>]', '', weight_url)\n",
|
||||
"\n",
|
||||
" print(\"Weight URL:\", cleaned_url)\n",
|
||||
" return cleaned_url\n",
|
||||
" else:\n",
|
||||
" print(\"No matching URL found in the meta description.\")\n",
|
||||
" except Exception as e:\n",
|
||||
" print(\"Error:\", e)\n",
|
||||
" finally:\n",
|
||||
" await browser.close()\n",
|
||||
"\n",
|
||||
" # Set the model link\n",
|
||||
" weights_url = await get_weight_url(model_link)\n",
|
||||
" model_link = weights_url\n",
|
||||
"else:\n",
|
||||
" model_link = model_link\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"model_link = '\"'+model_link+'\"'\n",
|
||||
"!curl -L $model_link > model.zip\n",
|
||||
"\n",
|
||||
@ -309,7 +361,7 @@
|
||||
"\n",
|
||||
"# !unzip model.zip -d model_dir/0/\n",
|
||||
"clear_output()\n",
|
||||
"print(\"\\033[92mModel with the name of \"+model_name+\" has been Imported to slot \"+model_slot)"
|
||||
"print(\"\\033[93mModel with the name of \"+model_name+\" has been Imported to slot \"+model_slot)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "_ZtbKUVUgN3G",
|
||||
|
Loading…
Reference in New Issue
Block a user