fix repo path
Browse files
app.py
CHANGED
@@ -12,30 +12,34 @@ from deoldify import device
|
|
12 |
from deoldify.device_id import DeviceId
|
13 |
from deoldify.visualize import *
|
14 |
# from huggingface_hub import HfApi, snapshot_download
|
15 |
-
from huggingface_hub import HfApi
|
16 |
|
17 |
os.system("pip freeze")
|
18 |
from collections.abc import Sized # Import Sized from collections.abc
|
19 |
# Suppress warnings
|
20 |
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
|
21 |
|
22 |
-
# Initialize Hugging Face API
|
23 |
-
api = HfApi()
|
24 |
-
|
25 |
-
device.set(device=DeviceId.CPU)
|
26 |
-
|
27 |
# Private repo settings
|
28 |
token = os.getenv("HF_TOKEN")
|
29 |
repo_id = "afondiel/image-colorizer-deoldify"
|
30 |
repo_type = "space"
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Download the snapshot from the space repository
|
33 |
-
snapshot_folder = api.snapshot_download(repo_id=repo_id, repo_type=repo_type, token=token)
|
34 |
|
35 |
device.set(device=DeviceId.GPU0)
|
36 |
# Load the pre-trained model
|
37 |
_colorizer = get_image_colorizer(root_folder=Path(snapshot_folder), artistic=True)
|
38 |
|
|
|
|
|
39 |
def colorizer_fn(input_img, render_factor):
|
40 |
"""
|
41 |
Colorize grayscale images/photos
|
|
|
12 |
from deoldify.device_id import DeviceId
|
13 |
from deoldify.visualize import *
|
14 |
# from huggingface_hub import HfApi, snapshot_download
|
15 |
+
from huggingface_hub import HfApi, HfFolder
|
16 |
|
17 |
os.system("pip freeze")
|
18 |
from collections.abc import Sized # Import Sized from collections.abc
|
19 |
# Suppress warnings
|
20 |
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
# Private repo settings
|
23 |
token = os.getenv("HF_TOKEN")
|
24 |
repo_id = "afondiel/image-colorizer-deoldify"
|
25 |
repo_type = "space"
|
26 |
|
27 |
+
device.set(device=DeviceId.CPU)
|
28 |
+
|
29 |
+
# Initialize Hugging Face API
|
30 |
+
api = HfApi(token=token)
|
31 |
+
|
32 |
+
HfFolder.save_token(token)
|
33 |
+
|
34 |
# Download the snapshot from the space repository
|
35 |
+
snapshot_folder = api.snapshot_download(repo_id=repo_id, repo_type=repo_type, revision="main", token=token)
|
36 |
|
37 |
device.set(device=DeviceId.GPU0)
|
38 |
# Load the pre-trained model
|
39 |
_colorizer = get_image_colorizer(root_folder=Path(snapshot_folder), artistic=True)
|
40 |
|
41 |
+
print(f"root_folder: {root_folder}")
|
42 |
+
|
43 |
def colorizer_fn(input_img, render_factor):
|
44 |
"""
|
45 |
Colorize grayscale images/photos
|