Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,23 @@ from PIL import Image
|
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
from safetensors.torch import load_model
|
| 6 |
from transformers import pipeline
|
| 7 |
-
import torch
|
| 8 |
from torch import nn
|
|
|
|
| 9 |
from torch.nn import functional as func_nn
|
| 10 |
from einops import rearrange
|
| 11 |
from huggingface_hub import PyTorchModelHubMixin
|
| 12 |
from torchvision import models
|
| 13 |
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# main model network
|
| 16 |
class SiameseNetwork(nn.Module, PyTorchModelHubMixin):
|
| 17 |
def __init__(self):
|
|
|
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
from safetensors.torch import load_model
|
| 6 |
from transformers import pipeline
|
| 7 |
+
import torch, cv2
|
| 8 |
from torch import nn
|
| 9 |
+
import numpy as np
|
| 10 |
from torch.nn import functional as func_nn
|
| 11 |
from einops import rearrange
|
| 12 |
from huggingface_hub import PyTorchModelHubMixin
|
| 13 |
from torchvision import models
|
| 14 |
|
| 15 |
|
| 16 |
+
def read_image(img, img_size=config.image_size):
|
| 17 |
+
img = np.array(img)
|
| 18 |
+
img = cv2.resize(img, (img_size, img_size)) # resize to mathc model input here
|
| 19 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 20 |
+
img = img / 255.0
|
| 21 |
+
|
| 22 |
+
return img
|
| 23 |
+
|
| 24 |
# main model network
|
| 25 |
class SiameseNetwork(nn.Module, PyTorchModelHubMixin):
|
| 26 |
def __init__(self):
|