MoC-IQA
Browse files- app.py +5 -3
- requirements.txt +8 -0
app.py
CHANGED
@@ -9,8 +9,10 @@ from utils.dataset.process import ToTensor, Normalize
|
|
9 |
import gradio as gr
|
10 |
|
11 |
def load_image(img_path):
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
d_img = cv2.resize(d_img, (224, 224), interpolation=cv2.INTER_CUBIC)
|
15 |
d_img = cv2.cvtColor(d_img, cv2.COLOR_BGR2RGB)
|
16 |
d_img = np.array(d_img).astype('float32') / 255
|
@@ -27,7 +29,7 @@ def predict(image):
|
|
27 |
config = parser.parse_args()
|
28 |
|
29 |
model = MoNet.MoNet(config).cuda()
|
30 |
-
model.load_state_dict(torch.load('
|
31 |
model.eval()
|
32 |
|
33 |
trans = torchvision.transforms.Compose([Normalize(0.5, 0.5), ToTensor()])
|
|
|
9 |
import gradio as gr
|
10 |
|
11 |
def load_image(img_path):
|
12 |
+
if isinstance(img_path, str):
|
13 |
+
d_img = cv2.imread(img_path, cv2.IMREAD_COLOR)
|
14 |
+
else:
|
15 |
+
d_img = cv2.cvtColor(np.asarray(img_path),cv2.COLOR_RGB2BGR)
|
16 |
d_img = cv2.resize(d_img, (224, 224), interpolation=cv2.INTER_CUBIC)
|
17 |
d_img = cv2.cvtColor(d_img, cv2.COLOR_BGR2RGB)
|
18 |
d_img = np.array(d_img).astype('float32') / 255
|
|
|
29 |
config = parser.parse_args()
|
30 |
|
31 |
model = MoNet.MoNet(config).cuda()
|
32 |
+
model.load_state_dict(torch.load('best_model.pkl'))
|
33 |
model.eval()
|
34 |
|
35 |
trans = torchvision.transforms.Compose([Normalize(0.5, 0.5), ToTensor()])
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
einops==0.6.1
|
2 |
+
numpy==1.22.4
|
3 |
+
openpyxl==3.0.9
|
4 |
+
Pillow==10.0.0
|
5 |
+
scipy==1.11.2
|
6 |
+
timm==0.5.4
|
7 |
+
torch==1.11.0
|
8 |
+
tqdm==4.61.2
|