Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,14 @@ from torchvision import transforms
|
|
| 7 |
import random
|
| 8 |
import numpy as np
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Load model
|
| 11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 12 |
|
|
@@ -81,6 +89,8 @@ def IQA_preprocess():
|
|
| 81 |
])
|
| 82 |
return transform
|
| 83 |
|
|
|
|
|
|
|
| 84 |
# Inference function
|
| 85 |
def predict_percept(image):
|
| 86 |
# If the image is passed as a PIL Image
|
|
|
|
| 7 |
import random
|
| 8 |
import numpy as np
|
| 9 |
|
| 10 |
+
def set_seed(seed):
|
| 11 |
+
random.seed(seed)
|
| 12 |
+
np.random.seed(seed)
|
| 13 |
+
torch.manual_seed(seed)
|
| 14 |
+
if torch.cuda.is_available():
|
| 15 |
+
torch.cuda.manual_seed(seed)
|
| 16 |
+
torch.cuda.manual_seed_all(seed)
|
| 17 |
+
|
| 18 |
# Load model
|
| 19 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 20 |
|
|
|
|
| 89 |
])
|
| 90 |
return transform
|
| 91 |
|
| 92 |
+
set_seed(3407)
|
| 93 |
+
|
| 94 |
# Inference function
|
| 95 |
def predict_percept(image):
|
| 96 |
# If the image is passed as a PIL Image
|