Spaces:
Runtime error
Runtime error
Commit ·
dcc6440
1
Parent(s): e5d65ce
new model
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import kornia.color as color
|
|
| 9 |
|
| 10 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 11 |
model = Generator()
|
| 12 |
-
model_weights = torch.load('
|
| 13 |
model.load_state_dict(model_weights)
|
| 14 |
model = model.to(device)
|
| 15 |
model.eval()
|
|
@@ -28,7 +28,6 @@ def preprocess(image):
|
|
| 28 |
L = image[[0], ...]
|
| 29 |
L, _ = normalize_lab(L, 0)
|
| 30 |
|
| 31 |
-
print(L.shape)
|
| 32 |
return L.unsqueeze(0)
|
| 33 |
|
| 34 |
def crop_to_original_size(image, original_size):
|
|
|
|
| 9 |
|
| 10 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 11 |
model = Generator()
|
| 12 |
+
model_weights = torch.load('gen6.pth', map_location=device, weights_only=True)
|
| 13 |
model.load_state_dict(model_weights)
|
| 14 |
model = model.to(device)
|
| 15 |
model.eval()
|
|
|
|
| 28 |
L = image[[0], ...]
|
| 29 |
L, _ = normalize_lab(L, 0)
|
| 30 |
|
|
|
|
| 31 |
return L.unsqueeze(0)
|
| 32 |
|
| 33 |
def crop_to_original_size(image, original_size):
|
model.pth
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 217659569
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f5b66fedbc088544c4d2dab70c531b5fc54e33745f25f68fc74d07ab5995fd61
|
| 3 |
size 217659569
|
model.py
CHANGED
|
@@ -2,6 +2,7 @@ import torch.nn as nn
|
|
| 2 |
import torch
|
| 3 |
import torch.nn.functional as F
|
| 4 |
|
|
|
|
| 5 |
# Dropout layer that works even in the evaluation mode
|
| 6 |
class DropoutAlways(nn.Dropout2d):
|
| 7 |
def forward(self, x):
|
|
|
|
| 2 |
import torch
|
| 3 |
import torch.nn.functional as F
|
| 4 |
|
| 5 |
+
|
| 6 |
# Dropout layer that works even in the evaluation mode
|
| 7 |
class DropoutAlways(nn.Dropout2d):
|
| 8 |
def forward(self, x):
|
utils.py
CHANGED
|
@@ -23,8 +23,8 @@ def decide_size(image):
|
|
| 23 |
height = image.size[1]
|
| 24 |
width = image.size[0]
|
| 25 |
|
| 26 |
-
new_height =
|
| 27 |
-
new_width =
|
| 28 |
|
| 29 |
while new_height < height:
|
| 30 |
new_height *= 2
|
|
|
|
| 23 |
height = image.size[1]
|
| 24 |
width = image.size[0]
|
| 25 |
|
| 26 |
+
new_height = 256
|
| 27 |
+
new_width = 256
|
| 28 |
|
| 29 |
while new_height < height:
|
| 30 |
new_height *= 2
|