Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,17 +31,6 @@ model.load_state_dict(checkpoints['params'])
|
|
| 31 |
|
| 32 |
model = model.to(device)
|
| 33 |
|
| 34 |
-
def path_to_tensor(path):
|
| 35 |
-
img = Image.open(path).convert('RGB')
|
| 36 |
-
img = pil_to_tensor(img).unsqueeze(0)
|
| 37 |
-
|
| 38 |
-
return img
|
| 39 |
-
def normalize_tensor(tensor):
|
| 40 |
-
|
| 41 |
-
max_value = torch.max(tensor)
|
| 42 |
-
min_value = torch.min(tensor)
|
| 43 |
-
output = (tensor - min_value)/(max_value)
|
| 44 |
-
return output
|
| 45 |
|
| 46 |
def pad_tensor(tensor, multiple = 8):
|
| 47 |
'''pad the tensor to be multiple of some number'''
|
|
@@ -54,7 +43,7 @@ def pad_tensor(tensor, multiple = 8):
|
|
| 54 |
return tensor
|
| 55 |
|
| 56 |
def process_img(image):
|
| 57 |
-
tensor =
|
| 58 |
_, _, H, W = tensor.shape
|
| 59 |
|
| 60 |
tensor = pad_tensor(tensor)
|
|
|
|
| 31 |
|
| 32 |
model = model.to(device)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
def pad_tensor(tensor, multiple = 8):
|
| 36 |
'''pad the tensor to be multiple of some number'''
|
|
|
|
| 43 |
return tensor
|
| 44 |
|
| 45 |
def process_img(image):
|
| 46 |
+
tensor = pil_to_tensor(image).unsqueeze(0).to(device)
|
| 47 |
_, _, H, W = tensor.shape
|
| 48 |
|
| 49 |
tensor = pad_tensor(tensor)
|