Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,29 +18,11 @@ else:
|
|
| 18 |
net.load_state_dict(torch.load(model_path,map_location="cpu"))
|
| 19 |
net.eval()
|
| 20 |
|
| 21 |
-
def image_size_by_min_resolution(
|
| 22 |
-
image: Image.Image,
|
| 23 |
-
resolution: Tuple,
|
| 24 |
-
resample=None,
|
| 25 |
-
):
|
| 26 |
-
w, h = image.size
|
| 27 |
-
|
| 28 |
-
image_min = min(w, h)
|
| 29 |
-
resolution_min = min(resolution)
|
| 30 |
-
|
| 31 |
-
scale_factor = image_min / resolution_min
|
| 32 |
-
|
| 33 |
-
resize_to: Tuple[int, int] = (
|
| 34 |
-
int(w // scale_factor),
|
| 35 |
-
int(h // scale_factor),
|
| 36 |
-
)
|
| 37 |
-
return resize_to
|
| 38 |
|
| 39 |
-
|
| 40 |
def resize_image(image):
|
| 41 |
image = image.convert('RGB')
|
| 42 |
-
|
| 43 |
-
image = image.resize(
|
| 44 |
return image
|
| 45 |
|
| 46 |
|
|
|
|
| 18 |
net.load_state_dict(torch.load(model_path,map_location="cpu"))
|
| 19 |
net.eval()
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
|
|
|
| 22 |
def resize_image(image):
|
| 23 |
image = image.convert('RGB')
|
| 24 |
+
model_input_size = (1024, 1024)
|
| 25 |
+
image = image.resize(model_input_size, Image.BILINEAR)
|
| 26 |
return image
|
| 27 |
|
| 28 |
|