Spaces:
Runtime error
Runtime error
Commit
•
be2809f
1
Parent(s):
34fb220
environment
Browse files- app.py +2 -33
- requirements.txt +2 -0
app.py
CHANGED
@@ -10,15 +10,10 @@ import cv2
|
|
10 |
import model_utils
|
11 |
from models.SSN import SSN
|
12 |
|
13 |
-
import matplotlib
|
14 |
-
matplotlib.use('TkAgg')
|
15 |
-
|
16 |
-
import numpy as np
|
17 |
-
import matplotlib.pyplot as plt
|
18 |
-
|
19 |
config_file = 'configs/SSN.yaml'
|
20 |
weight = 'weights/SSN/0000001760.pt'
|
21 |
device = torch.device('cuda:0')
|
|
|
22 |
model = model_utils.load_model(config_file, weight, SSN, device)
|
23 |
|
24 |
DEFAULT_INTENSITY = 0.9
|
@@ -141,35 +136,9 @@ def render_btn_fn(mask, ibl):
|
|
141 |
shadow = model.inference(x)
|
142 |
cur_shadow = np.copy(shadow)
|
143 |
|
144 |
-
# gamma
|
145 |
-
# shadow = np.power(shadow, 2.2)
|
146 |
-
# shadow = shadow * 0.8
|
147 |
-
# shadow = 1.0 - shadow
|
148 |
-
|
149 |
-
# composite the shadow
|
150 |
-
|
151 |
-
# shadow = shadow[..., None]
|
152 |
-
# mask = mask[..., None]
|
153 |
-
# ret = rgb * mask + (1.0 - mask) * shadow
|
154 |
ret, shadow = shadow_composite(cur_rgba, shadow, cur_intensity, cur_gamma)
|
155 |
|
156 |
-
#
|
157 |
-
# ret = (1.0-mask) * shadow
|
158 |
-
|
159 |
-
print('IBL range: {}/{} Shadow range: {} {}'.format(ibl.min(), ibl.max(), shadow.min(), shadow.max()))
|
160 |
-
|
161 |
-
plt.figure(figsize=(15, 10))
|
162 |
-
plt.subplot(1,3,1)
|
163 |
-
plt.imshow(mask)
|
164 |
-
plt.subplot(1,3,2)
|
165 |
-
plt.imshow(ibl)
|
166 |
-
plt.subplot(1,3,3)
|
167 |
-
plt.imshow(ret)
|
168 |
-
plt.savefig('tmp.png')
|
169 |
-
plt.close()
|
170 |
-
|
171 |
-
logging.info('Finished')
|
172 |
-
|
173 |
return ret, shadow
|
174 |
|
175 |
|
|
|
10 |
import model_utils
|
11 |
from models.SSN import SSN
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
config_file = 'configs/SSN.yaml'
|
14 |
weight = 'weights/SSN/0000001760.pt'
|
15 |
device = torch.device('cuda:0')
|
16 |
+
device = torch.device('cpu')
|
17 |
model = model_utils.load_model(config_file, weight, SSN, device)
|
18 |
|
19 |
DEFAULT_INTENSITY = 0.9
|
|
|
136 |
shadow = model.inference(x)
|
137 |
cur_shadow = np.copy(shadow)
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
ret, shadow = shadow_composite(cur_rgba, shadow, cur_intensity, cur_gamma)
|
140 |
|
141 |
+
# print('IBL range: {}/{} Shadow range: {} {}'.format(ibl.min(), ibl.max(), shadow.min(), shadow.max()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
return ret, shadow
|
143 |
|
144 |
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
opencv-python
|