Spaces:
Build error
Build error
local links updated
Browse files
app.py
CHANGED
|
@@ -22,14 +22,14 @@ import pandas as pd
|
|
| 22 |
import io
|
| 23 |
import base64
|
| 24 |
|
| 25 |
-
# checking the mounted drive and mounting if not done
|
| 26 |
-
if not os.path.exists('/content/gdrive'):
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
else:
|
| 30 |
-
|
| 31 |
|
| 32 |
-
list_c1 = torch.load('
|
| 33 |
|
| 34 |
class CustomDataset(torch.utils.data.Dataset):
|
| 35 |
def __init__(self, data):
|
|
@@ -54,7 +54,7 @@ def get_images():
|
|
| 54 |
pil_images = [transform_to_pil(image) for image in images]
|
| 55 |
return pil_images, labels.tolist()
|
| 56 |
|
| 57 |
-
list_c2 = torch.load('
|
| 58 |
dataset_c2 = CustomDataset(list_c2)
|
| 59 |
dataloader_c2 = torch.utils.data.DataLoader(dataset_c2, batch_size=10, shuffle=True)
|
| 60 |
def get_images_2():
|
|
@@ -173,7 +173,7 @@ class Network(nn.Module):
|
|
| 173 |
loaded_model_non_dann = Network()
|
| 174 |
loaded_model_non_dann = loaded_model_non_dann.to(device)
|
| 175 |
# Load the saved state dictionary
|
| 176 |
-
loaded_model_non_dann.load_state_dict(torch.load('
|
| 177 |
loaded_model_non_dann.eval()
|
| 178 |
|
| 179 |
## DANN
|
|
@@ -181,7 +181,7 @@ loaded_model_non_dann.eval()
|
|
| 181 |
loaded_model_dann = Network()
|
| 182 |
loaded_model_dann = loaded_model_dann.to(device)
|
| 183 |
# Load the saved state dictionary
|
| 184 |
-
loaded_model_dann.load_state_dict(torch.load('
|
| 185 |
loaded_model_dann.eval()
|
| 186 |
|
| 187 |
img_size = 28 # for mnist
|
|
@@ -329,7 +329,7 @@ def classify_image_inference(image):
|
|
| 329 |
|
| 330 |
def display_image():
|
| 331 |
# Load the image from a local file
|
| 332 |
-
image = Image.open("
|
| 333 |
return image
|
| 334 |
|
| 335 |
with gr.Blocks() as demo:
|
|
|
|
| 22 |
import io
|
| 23 |
import base64
|
| 24 |
|
| 25 |
+
# # checking the mounted drive and mounting if not done
|
| 26 |
+
# if not os.path.exists('/content/gdrive'):
|
| 27 |
+
# from google.colab import drive
|
| 28 |
+
# drive.mount('/content/gdrive')
|
| 29 |
+
# else:
|
| 30 |
+
# print("Google Drive is already mounted.")
|
| 31 |
|
| 32 |
+
list_c1 = torch.load('list_mnist_m_non_dann_misclassified_dann_classified.pt')
|
| 33 |
|
| 34 |
class CustomDataset(torch.utils.data.Dataset):
|
| 35 |
def __init__(self, data):
|
|
|
|
| 54 |
pil_images = [transform_to_pil(image) for image in images]
|
| 55 |
return pil_images, labels.tolist()
|
| 56 |
|
| 57 |
+
list_c2 = torch.load('list_mnist_m_non_dann_misclassified_dann_misclassified.pt')
|
| 58 |
dataset_c2 = CustomDataset(list_c2)
|
| 59 |
dataloader_c2 = torch.utils.data.DataLoader(dataset_c2, batch_size=10, shuffle=True)
|
| 60 |
def get_images_2():
|
|
|
|
| 173 |
loaded_model_non_dann = Network()
|
| 174 |
loaded_model_non_dann = loaded_model_non_dann.to(device)
|
| 175 |
# Load the saved state dictionary
|
| 176 |
+
loaded_model_non_dann.load_state_dict(torch.load('non_dann_26_06.pt', map_location=device), strict=False)
|
| 177 |
loaded_model_non_dann.eval()
|
| 178 |
|
| 179 |
## DANN
|
|
|
|
| 181 |
loaded_model_dann = Network()
|
| 182 |
loaded_model_dann = loaded_model_dann.to(device)
|
| 183 |
# Load the saved state dictionary
|
| 184 |
+
loaded_model_dann.load_state_dict(torch.load('dann_26_06.pt', map_location=device), strict=False)
|
| 185 |
loaded_model_dann.eval()
|
| 186 |
|
| 187 |
img_size = 28 # for mnist
|
|
|
|
| 329 |
|
| 330 |
def display_image():
|
| 331 |
# Load the image from a local file
|
| 332 |
+
image = Image.open("mnist-m.JPG")
|
| 333 |
return image
|
| 334 |
|
| 335 |
with gr.Blocks() as demo:
|