Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,15 @@ weights = torch.load('./checkpoints/caption_model.pt', map_location=torch.device
|
|
| 13 |
model = CaptionModel(tokenizer)
|
| 14 |
model.load_state_dict(weights['state_dict'])
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def decode_caption(idxs, tokenizer):
|
| 17 |
temp = []
|
| 18 |
for i in idxs:
|
|
|
|
| 13 |
model = CaptionModel(tokenizer)
|
| 14 |
model.load_state_dict(weights['state_dict'])
|
| 15 |
|
| 16 |
+
val_tfms = transforms.Compose([
|
| 17 |
+
# smaller edge of image resized to 256
|
| 18 |
+
transforms.Resize(256),
|
| 19 |
+
transforms.ToTensor(),
|
| 20 |
+
# normalize image for pre-trained model
|
| 21 |
+
transforms.Normalize((0.485, 0.456, 0.406),
|
| 22 |
+
(0.229, 0.224, 0.225))
|
| 23 |
+
])
|
| 24 |
+
|
| 25 |
def decode_caption(idxs, tokenizer):
|
| 26 |
temp = []
|
| 27 |
for i in idxs:
|