Spaces:
Runtime error
Runtime error
multi_classes is False
Browse files- __pycache__/utils.cpython-38.pyc +0 -0
- app.py +4 -1
- output.png +0 -0
__pycache__/utils.cpython-38.pyc
CHANGED
|
Binary files a/__pycache__/utils.cpython-38.pyc and b/__pycache__/utils.cpython-38.pyc differ
|
|
|
app.py
CHANGED
|
@@ -20,6 +20,8 @@ import torchvision
|
|
| 20 |
args = default_argument_parser().parse_args()
|
| 21 |
cfg = setup(args)
|
| 22 |
|
|
|
|
|
|
|
| 23 |
device = "cpu" # "cuda" if torch.cuda.is_available() else "cpu"
|
| 24 |
Ours, preprocess = models.load("CS-ViT-B/16", device=device, cfg=cfg, train_bool=False)
|
| 25 |
state_dict = torch.load("sketch_seg_best_miou.pth", map_location=device)
|
|
@@ -41,7 +43,7 @@ def run(sketch, caption, threshold, seed):
|
|
| 41 |
caption = caption.translate(translator).lower()
|
| 42 |
words = word_tokenize(caption)
|
| 43 |
classes = get_noun_phrase(words)
|
| 44 |
-
if len(classes) ==0:
|
| 45 |
classes = [caption]
|
| 46 |
|
| 47 |
# print(classes)
|
|
@@ -81,6 +83,7 @@ def run(sketch, caption, threshold, seed):
|
|
| 81 |
pixel_similarity[pixel_similarity < threshold] = 0
|
| 82 |
pixel_similarity_array = pixel_similarity.cpu().numpy().transpose(2, 0, 1)
|
| 83 |
|
|
|
|
| 84 |
# display_segmented_sketch(pixel_similarity_array, sketch2, classes, classes_colors, live=True)
|
| 85 |
|
| 86 |
# Find the class index with the highest similarity for each pixel
|
|
|
|
| 20 |
args = default_argument_parser().parse_args()
|
| 21 |
cfg = setup(args)
|
| 22 |
|
| 23 |
+
multi_classes = False
|
| 24 |
+
|
| 25 |
device = "cpu" # "cuda" if torch.cuda.is_available() else "cpu"
|
| 26 |
Ours, preprocess = models.load("CS-ViT-B/16", device=device, cfg=cfg, train_bool=False)
|
| 27 |
state_dict = torch.load("sketch_seg_best_miou.pth", map_location=device)
|
|
|
|
| 43 |
caption = caption.translate(translator).lower()
|
| 44 |
words = word_tokenize(caption)
|
| 45 |
classes = get_noun_phrase(words)
|
| 46 |
+
if len(classes) ==0 or multi_classes == False:
|
| 47 |
classes = [caption]
|
| 48 |
|
| 49 |
# print(classes)
|
|
|
|
| 83 |
pixel_similarity[pixel_similarity < threshold] = 0
|
| 84 |
pixel_similarity_array = pixel_similarity.cpu().numpy().transpose(2, 0, 1)
|
| 85 |
|
| 86 |
+
|
| 87 |
# display_segmented_sketch(pixel_similarity_array, sketch2, classes, classes_colors, live=True)
|
| 88 |
|
| 89 |
# Find the class index with the highest similarity for each pixel
|
output.png
CHANGED
|
|