sb2
Browse files
app.py
CHANGED
|
@@ -24,22 +24,21 @@ net_c=net_c.to('cpu')
|
|
| 24 |
#net_c=net_c.to('cuda')
|
| 25 |
net_i.eval().to('cuda')
|
| 26 |
net_c.eval().to('cuda')
|
| 27 |
-
|
| 28 |
def align(x1):
|
| 29 |
h, w = x1.shape[:2]
|
| 30 |
h, w = h // 32 * 32, w // 32 * 32
|
| 31 |
x1 = np.resize(x1, (h, w, x1.shape[2]))
|
| 32 |
return x1
|
| 33 |
|
| 34 |
-
|
| 35 |
-
img=align(img)
|
| 36 |
-
img=TF.to_tensor(img)
|
| 37 |
-
image_tensor=img.unsqueeze(0)
|
| 38 |
-
return predict(image_tensor)
|
| 39 |
|
| 40 |
@spaces.GPU(duration=120)
|
| 41 |
-
def predict(
|
| 42 |
with torch.no_grad():
|
|
|
|
|
|
|
|
|
|
| 43 |
ipt=net_c(image_tensor)
|
| 44 |
image_tensor = image_tensor.half()
|
| 45 |
ipt = ipt.half()
|
|
|
|
| 24 |
#net_c=net_c.to('cuda')
|
| 25 |
net_i.eval().to('cuda')
|
| 26 |
net_c.eval().to('cuda')
|
| 27 |
+
|
| 28 |
def align(x1):
|
| 29 |
h, w = x1.shape[:2]
|
| 30 |
h, w = h // 32 * 32, w // 32 * 32
|
| 31 |
x1 = np.resize(x1, (h, w, x1.shape[2]))
|
| 32 |
return x1
|
| 33 |
|
| 34 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
@spaces.GPU(duration=120)
|
| 37 |
+
def predict(img):
|
| 38 |
with torch.no_grad():
|
| 39 |
+
img=align(img)
|
| 40 |
+
img=TF.to_tensor(img)
|
| 41 |
+
image_tensor=img.unsqueeze(0)
|
| 42 |
ipt=net_c(image_tensor)
|
| 43 |
image_tensor = image_tensor.half()
|
| 44 |
ipt = ipt.half()
|