Spaces:
Running
on
Zero
Running
on
Zero
loading models at start up
Browse files
app.py
CHANGED
@@ -12,10 +12,8 @@ DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
12 |
# Instead of loading models at startup, we'll create a cache for models
|
13 |
model_cache = {}
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
model_cache[model_version] = load_models(model_version, device=DEVICE)
|
18 |
-
return model_cache[model_version]
|
19 |
|
20 |
def generate_pipeline(models):
|
21 |
def pipeline_func(image, **kwargs):
|
@@ -34,7 +32,7 @@ def process_image(image, model_version):
|
|
34 |
image = image.astype(np.single) / 255.
|
35 |
|
36 |
# Get or load the selected model
|
37 |
-
models =
|
38 |
pipeline_func = generate_pipeline(models)
|
39 |
|
40 |
result = pipeline_func(image, device=DEVICE, resize_conf=1024)
|
@@ -87,13 +85,6 @@ with gr.Blocks(
|
|
87 |
gr.Markdown(
|
88 |
"""
|
89 |
# Colorful Diffuse Intrinsic Image Decomposition in the Wild
|
90 |
-
<p align="center">
|
91 |
-
<a title="Website" href="https://yaksoy.github.io/ColorfulShading/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
92 |
-
<img src="https://www.obukhov.ai/img/badges/badge-website.svg">
|
93 |
-
</a>
|
94 |
-
<a title="Github" href="https://github.com/compphoto/Intrinsic" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
95 |
-
<img src="https://img.shields.io/github/stars/compphoto/Intrinsic?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
|
96 |
-
</a>
|
97 |
"""
|
98 |
)
|
99 |
|
@@ -108,8 +99,17 @@ with gr.Blocks(
|
|
108 |
)
|
109 |
|
110 |
gr.Markdown("""
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
""")
|
114 |
|
115 |
# Gallery-style layout for all images
|
|
|
12 |
# Instead of loading models at startup, we'll create a cache for models
|
13 |
model_cache = {}
|
14 |
|
15 |
+
model_cache['v2'] = load_models('v2', device=DEVICE)
|
16 |
+
model_cache['v2.1'] = load_models('v2.1', device=DEVICE)
|
|
|
|
|
17 |
|
18 |
def generate_pipeline(models):
|
19 |
def pipeline_func(image, **kwargs):
|
|
|
32 |
image = image.astype(np.single) / 255.
|
33 |
|
34 |
# Get or load the selected model
|
35 |
+
models = model_cache[model_version]
|
36 |
pipeline_func = generate_pipeline(models)
|
37 |
|
38 |
result = pipeline_func(image, device=DEVICE, resize_conf=1024)
|
|
|
85 |
gr.Markdown(
|
86 |
"""
|
87 |
# Colorful Diffuse Intrinsic Image Decomposition in the Wild
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
"""
|
89 |
)
|
90 |
|
|
|
99 |
)
|
100 |
|
101 |
gr.Markdown("""
|
102 |
+
<p align="center">
|
103 |
+
<a title="Website" href="https://yaksoy.github.io/ColorfulShading/" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
104 |
+
<img src="https://www.obukhov.ai/img/badges/badge-website.svg">
|
105 |
+
</a>
|
106 |
+
<a title="Github" href="https://github.com/compphoto/Intrinsic" target="_blank" rel="noopener noreferrer" style="display: inline-block;">
|
107 |
+
<img src="https://img.shields.io/github/stars/compphoto/Intrinsic?label=GitHub%20%E2%98%85&logo=github&color=C8C" alt="badge-github-stars">
|
108 |
+
</a>
|
109 |
+
|
110 |
+
**V2**: Original weights from the paper.
|
111 |
+
|
112 |
+
**V2.1**: More albedo detail and improved diffuse shading estimation.
|
113 |
""")
|
114 |
|
115 |
# Gallery-style layout for all images
|