File size: 1,031 Bytes
c5d1577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import os
from huggingface_hub import hf_hub_download
from utils import custom_drive_cache_dir, get_drive

HF_TOKEN = os.getenv("HF_TOKEN")

MANGA_LINE_EXTRACTION_MODEL = "https://github.com/ljsabc/MangaLineExtraction_PyTorch/releases/download/v1/erika.pth"
ANIME2SKETCH_MODEL = {"REPO_ID": "p1atdev/Anime2Sketch", "FILENAME": "netG.pth"}


def download_manga_line_extraction_model():
    if os.path.exists("./models/erika.pth"):
        return


def download_anime2sketch_model():
    if os.path.exists("./models/netG.pth"):
        return

    drive = get_drive("./models/netG.pth")
    with custom_drive_cache_dir(drive) as cache_dir:
        hf_hub_download(
            repo_id=ANIME2SKETCH_MODEL["REPO_ID"],
            filename=ANIME2SKETCH_MODEL["FILENAME"],
            local_dir="./models",
            use_auth_token=HF_TOKEN,
            local_dir_use_symlinks=False,
            cache_dir=cache_dir,
        )


def setup():
    download_manga_line_extraction_model()
    download_anime2sketch_model()