Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ from fastai.callback import *
|
|
| 11 |
from pathlib import Path
|
| 12 |
import random
|
| 13 |
import PIL
|
| 14 |
-
import torchvision.transforms as
|
| 15 |
from albumentations import *
|
| 16 |
|
| 17 |
def get_y_fn (x):
|
|
@@ -66,7 +66,7 @@ repo_id = "paascorb/practica3_Segmentation"
|
|
| 66 |
learner = from_pretrained_fastai(repo_id)
|
| 67 |
|
| 68 |
def transform_image(image):
|
| 69 |
-
my_transforms =
|
| 70 |
transforms.Normalize(
|
| 71 |
[0.485, 0.456, 0.406],
|
| 72 |
[0.229, 0.224, 0.225])])
|
|
@@ -75,7 +75,7 @@ def transform_image(image):
|
|
| 75 |
|
| 76 |
def predict(img):
|
| 77 |
img = PIL.Image.fromarray(img, "RGB")
|
| 78 |
-
|
| 79 |
tensor = transform_image(image=img)
|
| 80 |
|
| 81 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
| 11 |
from pathlib import Path
|
| 12 |
import random
|
| 13 |
import PIL
|
| 14 |
+
import torchvision.transforms as transformss
|
| 15 |
from albumentations import *
|
| 16 |
|
| 17 |
def get_y_fn (x):
|
|
|
|
| 66 |
learner = from_pretrained_fastai(repo_id)
|
| 67 |
|
| 68 |
def transform_image(image):
|
| 69 |
+
my_transforms = transformss.Compose([transforms.ToTensor(),
|
| 70 |
transforms.Normalize(
|
| 71 |
[0.485, 0.456, 0.406],
|
| 72 |
[0.229, 0.224, 0.225])])
|
|
|
|
| 75 |
|
| 76 |
def predict(img):
|
| 77 |
img = PIL.Image.fromarray(img, "RGB")
|
| 78 |
+
image = transformss.Resize((480,640))(img)
|
| 79 |
tensor = transform_image(image=img)
|
| 80 |
|
| 81 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|