Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ CLASSES = ["NONE", "INFECTION", "ISCHAEMIA", "BOTH"]
|
|
| 14 |
# 2️⃣ تعريف نموذج DenseShuffleGCANet
|
| 15 |
# -------------------------------
|
| 16 |
class DenseShuffleGCANet(nn.Module):
|
| 17 |
-
def __init__(self, num_classes=4, handcrafted_feature_dim=
|
| 18 |
super(DenseShuffleGCANet, self).__init__()
|
| 19 |
# مثال على backbone، عدلي حسب الكود الأصلي
|
| 20 |
self.backbone = nn.Sequential(
|
|
@@ -36,7 +36,7 @@ class DenseShuffleGCANet(nn.Module):
|
|
| 36 |
# -------------------------------
|
| 37 |
# 3️⃣ تحميل النموذج مع weights
|
| 38 |
# -------------------------------
|
| 39 |
-
model = DenseShuffleGCANet(num_classes=4, handcrafted_feature_dim=
|
| 40 |
model.load_state_dict(torch.load("best_model_2.pth", map_location=torch.device('cpu')))
|
| 41 |
model.eval()
|
| 42 |
|
|
@@ -44,7 +44,7 @@ model.eval()
|
|
| 44 |
# 4️⃣ دالة استخراج الخصائص اليدوية
|
| 45 |
# -------------------------------
|
| 46 |
def extract_handcrafted_features(image_array):
|
| 47 |
-
features = np.random.rand(
|
| 48 |
return torch.tensor(features)
|
| 49 |
|
| 50 |
# -------------------------------
|
|
|
|
| 14 |
# 2️⃣ تعريف نموذج DenseShuffleGCANet
|
| 15 |
# -------------------------------
|
| 16 |
class DenseShuffleGCANet(nn.Module):
|
| 17 |
+
def __init__(self, num_classes=4, handcrafted_feature_dim=41):
|
| 18 |
super(DenseShuffleGCANet, self).__init__()
|
| 19 |
# مثال على backbone، عدلي حسب الكود الأصلي
|
| 20 |
self.backbone = nn.Sequential(
|
|
|
|
| 36 |
# -------------------------------
|
| 37 |
# 3️⃣ تحميل النموذج مع weights
|
| 38 |
# -------------------------------
|
| 39 |
+
model = DenseShuffleGCANet(num_classes=4, handcrafted_feature_dim=41)
|
| 40 |
model.load_state_dict(torch.load("best_model_2.pth", map_location=torch.device('cpu')))
|
| 41 |
model.eval()
|
| 42 |
|
|
|
|
| 44 |
# 4️⃣ دالة استخراج الخصائص اليدوية
|
| 45 |
# -------------------------------
|
| 46 |
def extract_handcrafted_features(image_array):
|
| 47 |
+
features = np.random.rand(41).astype(np.float32) # عدلي حسب خصائصك الحقيقية
|
| 48 |
return torch.tensor(features)
|
| 49 |
|
| 50 |
# -------------------------------
|