fix the model path
Browse files
app.py
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_imageslider import ImageSlider
|
3 |
import numpy as np
|
@@ -7,11 +11,15 @@ import fastai
|
|
7 |
from deoldify import device
|
8 |
from deoldify.device_id import DeviceId
|
9 |
from deoldify.visualize import *
|
|
|
10 |
|
11 |
-
|
12 |
from collections.abc import Sized # Import Sized from collections.abc
|
13 |
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
|
14 |
|
|
|
|
|
|
|
15 |
# Set the device to use for computation
|
16 |
# choices: CPU, GPU0...GPU7
|
17 |
if torch.cuda.is_available():
|
@@ -20,7 +28,7 @@ else:
|
|
20 |
device.set(device=DeviceId.CPU)
|
21 |
|
22 |
# Load the pre-trained model
|
23 |
-
colorizer = get_image_colorizer(artistic=True)
|
24 |
|
25 |
|
26 |
def colorizer_fn(input_img, render_factor):
|
|
|
1 |
+
import os
|
2 |
+
import warnings
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
import gradio as gr
|
6 |
from gradio_imageslider import ImageSlider
|
7 |
import numpy as np
|
|
|
11 |
from deoldify import device
|
12 |
from deoldify.device_id import DeviceId
|
13 |
from deoldify.visualize import *
|
14 |
+
from huggingface_hub import snapshot_download
|
15 |
|
16 |
+
os.system("pip freeze")
|
17 |
from collections.abc import Sized # Import Sized from collections.abc
|
18 |
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
|
19 |
|
20 |
+
|
21 |
+
snapshot_folder = snapshot_download(repo_id="afondiel/image-colorizer-deoldify")
|
22 |
+
|
23 |
# Set the device to use for computation
|
24 |
# choices: CPU, GPU0...GPU7
|
25 |
if torch.cuda.is_available():
|
|
|
28 |
device.set(device=DeviceId.CPU)
|
29 |
|
30 |
# Load the pre-trained model
|
31 |
+
colorizer = get_image_colorizer(root_folder=Path(snapshot_folder), artistic=True)
|
32 |
|
33 |
|
34 |
def colorizer_fn(input_img, render_factor):
|