Spaces:
Sleeping
Sleeping
Commit
·
eb93b7d
1
Parent(s):
b62208c
minor bug fix!
Browse files
app.py
CHANGED
|
@@ -10,7 +10,8 @@ from torchvision.transforms import v2
|
|
| 10 |
|
| 11 |
from model import MAE_ViT, MAE_Encoder, MAE_Decoder, MAE_Encoder_FeatureExtractor
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
device = torch.device("cpu")
|
| 15 |
|
| 16 |
model_name = "model/no_mode/vit-t-mae-pretrain.pt"
|
|
@@ -128,19 +129,27 @@ def visualize_single_image_pca_mode(image_path):
|
|
| 128 |
|
| 129 |
return np.array(plt.imread("output.png"))
|
| 130 |
|
| 131 |
-
|
| 132 |
gr.components.Image(type="filepath", label="Input Image"),
|
| 133 |
]
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
gr.components.Image(type="numpy", label="Output Image"),
|
| 137 |
]
|
| 138 |
|
| 139 |
inference_no_mode = gr.Interface(
|
| 140 |
fn=visualize_single_image_no_mode,
|
| 141 |
-
inputs=
|
| 142 |
-
outputs=
|
| 143 |
-
examples=
|
| 144 |
cache_examples = False,
|
| 145 |
title="MAE-ViT Image Reconstruction",
|
| 146 |
description="This is a demo of the MAE-ViT model for image reconstruction.",
|
|
@@ -148,9 +157,9 @@ inference_no_mode = gr.Interface(
|
|
| 148 |
|
| 149 |
inference_pca_mode = gr.Interface(
|
| 150 |
fn=visualize_single_image_pca_mode,
|
| 151 |
-
inputs=
|
| 152 |
-
outputs=
|
| 153 |
-
examples=
|
| 154 |
title="MAE-ViT Image Reconstruction",
|
| 155 |
description="This is a demo of the MAE-ViT model for image reconstruction.",
|
| 156 |
)
|
|
|
|
| 10 |
|
| 11 |
from model import MAE_ViT, MAE_Encoder, MAE_Decoder, MAE_Encoder_FeatureExtractor
|
| 12 |
|
| 13 |
+
path_1 = [['images/cat.jpg'], ['images/dog.jpg'], ['images/horse.jpg'], ['images/airplane.jpg'], ['images/truck.jpg']]
|
| 14 |
+
path_2 = [['images/cat.jpg'], ['images/dog.jpg'], ['images/horse.jpg'], ['images/airplane.jpg'], ['images/truck.jpg']]
|
| 15 |
device = torch.device("cpu")
|
| 16 |
|
| 17 |
model_name = "model/no_mode/vit-t-mae-pretrain.pt"
|
|
|
|
| 129 |
|
| 130 |
return np.array(plt.imread("output.png"))
|
| 131 |
|
| 132 |
+
inputs_image_1 = [
|
| 133 |
gr.components.Image(type="filepath", label="Input Image"),
|
| 134 |
]
|
| 135 |
|
| 136 |
+
outputs_image_1 = [
|
| 137 |
+
gr.components.Image(type="numpy", label="Output Image"),
|
| 138 |
+
]
|
| 139 |
+
|
| 140 |
+
inputs_image_2 = [
|
| 141 |
+
gr.components.Image(type="filepath", label="Input Image"),
|
| 142 |
+
]
|
| 143 |
+
|
| 144 |
+
outputs_image_2 = [
|
| 145 |
gr.components.Image(type="numpy", label="Output Image"),
|
| 146 |
]
|
| 147 |
|
| 148 |
inference_no_mode = gr.Interface(
|
| 149 |
fn=visualize_single_image_no_mode,
|
| 150 |
+
inputs=inputs_image_1,
|
| 151 |
+
outputs=outputs_image_1,
|
| 152 |
+
examples=path_1,
|
| 153 |
cache_examples = False,
|
| 154 |
title="MAE-ViT Image Reconstruction",
|
| 155 |
description="This is a demo of the MAE-ViT model for image reconstruction.",
|
|
|
|
| 157 |
|
| 158 |
inference_pca_mode = gr.Interface(
|
| 159 |
fn=visualize_single_image_pca_mode,
|
| 160 |
+
inputs=inputs_image_2,
|
| 161 |
+
outputs=outputs_image_2,
|
| 162 |
+
examples=path_2,
|
| 163 |
title="MAE-ViT Image Reconstruction",
|
| 164 |
description="This is a demo of the MAE-ViT model for image reconstruction.",
|
| 165 |
)
|