Spaces:
Running on Zero
Running on Zero
moved resize to tf compose
Browse files
app.py
CHANGED
|
@@ -35,6 +35,7 @@ model.eval()
|
|
| 35 |
|
| 36 |
tf = v2.Compose([
|
| 37 |
v2.ToImage(),
|
|
|
|
| 38 |
v2.ToDtype(torch.float32, scale=True),
|
| 39 |
])
|
| 40 |
|
|
@@ -42,10 +43,11 @@ tf = v2.Compose([
|
|
| 42 |
def predict(image):
|
| 43 |
if image is None:
|
| 44 |
return None
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
with torch.no_grad():
|
| 51 |
outputs = model(img_tensor)
|
|
|
|
| 35 |
|
| 36 |
tf = v2.Compose([
|
| 37 |
v2.ToImage(),
|
| 38 |
+
v2.Resize((64, 64)),
|
| 39 |
v2.ToDtype(torch.float32, scale=True),
|
| 40 |
])
|
| 41 |
|
|
|
|
| 43 |
def predict(image):
|
| 44 |
if image is None:
|
| 45 |
return None
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
pil_img = Image.fromarray(image.astype('uint8'), 'RGB')
|
| 49 |
+
|
| 50 |
+
img_tensor = tf(pil_img).unsqueeze(0).to(device)
|
| 51 |
|
| 52 |
with torch.no_grad():
|
| 53 |
outputs = model(img_tensor)
|