Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

colab still disconnects even i am in colab pro now plz help(stack overflow: No module named 'pydantic._internal._std_types_schema') #76

Open
andersenryu opened this issue Aug 14, 2023 · 1 comment

Comments

@andersenryu
Copy link

stack overflow
When i use this notebook colab pro just stops and stack overflow happens, and when i try to reinstall it, this happens. Does anybody know how to solve this stack overflow problem?

@andersenryu
Copy link
Author

@title ## Custom Download Corner

import os
import time
from pydantic import BaseModel
from colablib.utils.py_utils import get_filename
from colablib.sd_models.downloader import aria2_download, download
from colablib.utils.ubuntu_utils import unionfuse
from colablib.utils.git_utils import clone_repo
from colablib.colored_print import cprint, print_line
from colablib.utils.config_utils import read_config

%store -r

@markdown

@markdown ### Download from Custom URLs

@markdown - Use comma separation for multiple URLs, e.g. url1, url2, url3.

@markdown - To load Google Drive, use fuse: followed by path, e.g. fuse:/content/MyDrive/LoRA.

@markdown - Copy your model path from Google Drive to URL fields to copy your model to the web UI models directory.

custom_model_url = "https://huggingface.co/emmajoanne/models/resolve/main/breakdomain_M2000.safetensors,https://civitai.com/api/download/models/70458,https://civitai.com/api/download/models/5036,https://civitai.com/api/download/models/60506,https://civitai.com/api/download/models/16836,https://civitai.com/api/download/models/5038,https://civitai.com/api/download/models/109123,https://civitai.com/api/download/models/41233" # @param {'type': 'string'}
custom_vae_url = "" # @param {'type': 'string'}
custom_embedding_url = "" # @param {'type': 'string'}
custom_LoRA_url = "https://civitai.com/api/download/models/10431,https://civitai.com/api/download/models/104894,https://civitai.com/api/download/models/11362,https://civitai.com/api/download/models/9830,https://civitai.com/api/download/models/13312,https://drive.google.com/file/d/1A1qCtzGJfD6H3AnQsOEi7zKUGZnS-t7X/view?usp=share_link,https://civitai.com/api/download/models/34570,https://civitai.com/api/download/models/13113,https://civitai.com/api/download/models/100643,https://civitai.com/api/download/models/7844,https://civitai.com/api/download/models/8278,https://civitai.com/api/download/models/85156,https://civitai.com/api/download/models/64225,https://civitai.com/api/download/models/101618,https://civitai.com/api/download/models/25591,https://civitai.com/api/download/models/89189,https://civitai.com/api/download/models/11363,https://civitai.com/api/download/models/58122,https://civitai.com/api/download/models/54333,https://civitai.com/api/download/models/54606,https://civitai.com/api/download/models/29004,https://civitai.com/api/download/models/78464,https://civitai.com/api/download/models/23195,https://civitai.com/api/download/models/74042,https://civitai.com/api/download/models/44769,https://civitai.com/api/download/models/110769,https://civitai.com/api/download/models/46845,https://civitai.com/api/download/models/56298,https://civitai.com/api/download/models/100241,https://civitai.com/api/download/models/99737,https://civitai.com/api/download/models/99632,https://civitai.com/api/download/models/30001,https://civitai.com/api/download/models/62773,https://civitai.com/api/download/models/44109,https://civitai.com/api/download/models/65674,https://civitai.com/api/download/models/38733,https://civitai.com/api/download/models/104807,https://civitai.com/api/download/models/122115,https://civitai.com/api/download/models/74456,https://civitai.com/api/download/models/98375,https://civitai.com/api/download/models/8776,https://civitai.com/api/download/models/29154,https://civitai.com/api/download/models/18461,https://civitai.com/api/download/models/23258,https://civitai.com/api/download/models/119144,https://civitai.com/api/download/models/85914,https://civitai.com/api/download/models/93432,https://civitai.com/api/download/models/87959,https://civitai.com/api/download/models/64899,https://civitai.com/api/download/models/118844,https://civitai.com/api/download/models/41550,https://civitai.com/api/download/models/48834,https://civitai.com/api/download/models/97833,https://civitai.com/api/download/models/36435,https://civitai.com/api/download/models/84769,https://civitai.com/api/download/models/121410,https://civitai.com/api/download/models/15588,https://civitai.com/api/download/models/110715,https://civitai.com/api/download/models/78755,https://civitai.com/api/download/models/59108,https://civitai.com/api/download/models/31432,https://civitai.com/api/download/models/11156,https://civitai.com/api/download/models/37826,https://civitai.com/api/download/models/94939,https://civitai.com/api/download/models/42711,https://civitai.com/api/download/models/50862,https://civitai.com/api/download/models/48066,https://civitai.com/api/download/models/51705,https://civitai.com/api/download/models/18964,https://civitai.com/api/download/models/107212,https://civitai.com/api/download/models/125394,https://civitai.com/api/download/models/66886,https://civitai.com/api/download/models/78250,https://civitai.com/api/download/models/83285,https://civitai.com/api/download/models/124749,https://civitai.com/api/download/models/130228,https://civitai.com/api/download/models/46695,https://civitai.com/api/download/models/66725,https://civitai.com/api/download/models/23879,https://civitai.com/api/download/models/51306,https://civitai.com/api/download/models/16790,https://civitai.com/api/download/models/112696,https://civitai.com/api/download/models/61189,https://civitai.com/api/download/models/135309,https://civitai.com/api/download/models/138670" # @param {'type': 'string'}
custom_hypernetwork_url = "" # @param {'type': 'string'}
custom_extensions_url = "" # @param {'type': 'string'}
custom_upscaler_url = "" # @param {'type': 'string'}

@markdown ###
NEW Download from Textfile

@markdown - Provide a custom download URL for a .txt file instead of using the URL field. Edit the file: /content/download_list.txt.

@markdown - Available hashtags: #model, #vae, #embedding, #lora, #hypernetwork, #extensions, #upscaler.

@markdown - Or you can input your .txt file in custom_download_list_url below. Works for pastebin.

custom_download_list_url = "" # @param {'type': 'string'}

class CustomDirs(BaseModel):
url: str
dst: str

custom_dirs = {
"model" : CustomDirs(url=custom_model_url, dst=models_dir),
"vae" : CustomDirs(url=custom_vae_url, dst=vaes_dir),
"embedding" : CustomDirs(url=custom_embedding_url, dst=embeddings_dir),
"lora" : CustomDirs(url=custom_LoRA_url, dst=lora_dir),
"hypernetwork": CustomDirs(url=custom_hypernetwork_url, dst=hypernetworks_dir),
"extensions" : CustomDirs(url=custom_extensions_url, dst=extensions_dir),
"upscaler" : CustomDirs(url=custom_upscaler_url, dst=esrgan_dir)
}

def fuse(url, key, dst):
if "extensions" in key:
cprint(f"Folder can't be fused, skipping...")
return

path = url.split("fuse:")[1].strip()
category_dir = os.path.join(fused_dir, key)
if os.path.exists(category_dir):
    cprint(f"Folder '{category_dir}' is already fused, skipping...", color="yellow")
    return

cprint(f"Fusing process started for PATH: '{path}'", color="green")
unionfuse(category_dir, path, dst)
cprint(f"Fusing process completed. Valid '{key}' folder located at: '{category_dir}' ", color="green")

def parse_urls(filename):
content = read_config(filename)
lines = content.strip().split('\n')
result = {}
key = ''
for line in lines:
if not line.strip():
continue
if line.startswith('//'):
continue
if line.startswith('#'):
key = line[1:].lower()
result[key] = []
else:
urls = [url.strip() for url in line.split(',') if url.strip() != '']
result[key].extend(urls)
return result

def custom_download(custom_dirs):
for key, value in custom_dirs.items():
urls = value.url.split(",") # Split the comma-separated URLs
dst = value.dst

    if value.url:
        print_line(80, color="green")
        cprint(f" [-] Downloading Custom {key}...", color="flat_yellow")

    for url in urls:
        url = url.strip()  # Remove leading/trailing whitespaces from each URL
        if url != "":
            print_line(80, color="green")
            if "|" in url:
                url, filename = map(str.strip, url.split("|"))
                if not filename.endswith((".safetensors", ".ckpt", ".pt", "pth")):
                    filename = filename + os.path.splitext(get_filename(url))[1]
            else:
                if not url.startswith("fuse:"):
                    filename = get_filename(url)

            if url.startswith("fuse:"):
                fuse(url, key, dst)
            elif key == "extensions":
                clone_repo(url, cwd=dst)
            else:
                download(url=url, filename=filename, dst=dst, quiet=False)

def download_from_textfile(filename):
for key, urls in parse_urls(filename).items():
key_lower = key.lower()
if key_lower in custom_dirs:
if custom_dirs[key_lower].url:
custom_dirs[key_lower].url += ',' + ','.join(urls)
else:
custom_dirs[key_lower].url = ','.join(urls)
else:
cprint(f"Warning: Category '{key}' from the file is not found in custom_dirs.", color="yellow")

def custom_download_list(url):
filename = "custom_download_list.txt"
filepath = os.path.join(root_dir, filename)
if os.path.exists(filepath):
os.remove(filepath)
if 'pastebin.com' in url:
if 'raw' not in url:
url = url.replace('pastebin.com', 'pastebin.com/raw')
download(url=url, filename=filename, dst=root_dir, quiet=True)
return filepath

def main():
start_time = time.time()
textfile_path = download_list
if custom_download_list_url:
textfile_path = custom_download_list(custom_download_list_url)
download_from_textfile(textfile_path)
custom_download(custom_dirs)

elapsed_time  = py_utils.calculate_elapsed_time(start_time)
print_line(80, color="green")
cprint(f"Download finished. Took {elapsed_time}.", color="flat_yellow")
cprint("All is done! Go to the next step.", color="flat_yellow")
print_line(80, color="green")

main()

this was the code for the downloading btw

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant