Spaces:
Sleeping
Sleeping
nishantguvvada
commited on
Commit
•
ddf3da3
1
Parent(s):
6547b74
Update app.py
Browse files
app.py
CHANGED
@@ -55,7 +55,6 @@ IMG_CHANNELS = 3
|
|
55 |
ATTENTION_DIM = 512 # size of dense layer in Attention
|
56 |
VOCAB_SIZE = 20000
|
57 |
|
58 |
-
|
59 |
# We will override the default standardization of TextVectorization to preserve
|
60 |
# "<>" characters, so we preserve the tokens for the <start> and <end>.
|
61 |
def standardize(inputs):
|
@@ -64,7 +63,6 @@ def standardize(inputs):
|
|
64 |
inputs, r"[!\"#$%&\(\)\*\+.,-/:;=?@\[\\\]^_`{|}~]?", ""
|
65 |
)
|
66 |
|
67 |
-
|
68 |
# Choose the most frequent words from the vocabulary & remove punctuation etc.
|
69 |
tokenizer = TextVectorization(
|
70 |
max_tokens=VOCAB_SIZE,
|
@@ -77,11 +75,6 @@ word_to_index = StringLookup(
|
|
77 |
mask_token="", vocabulary=tokenizer.get_vocabulary()
|
78 |
)
|
79 |
|
80 |
-
# Lookup table: Index -> Word
|
81 |
-
index_to_word = StringLookup(
|
82 |
-
mask_token="", vocabulary=tokenizer.get_vocabulary(), invert=True
|
83 |
-
)
|
84 |
-
|
85 |
|
86 |
## Probabilistic prediction using the trained model
|
87 |
def predict_caption(file):
|
|
|
55 |
ATTENTION_DIM = 512 # size of dense layer in Attention
|
56 |
VOCAB_SIZE = 20000
|
57 |
|
|
|
58 |
# We will override the default standardization of TextVectorization to preserve
|
59 |
# "<>" characters, so we preserve the tokens for the <start> and <end>.
|
60 |
def standardize(inputs):
|
|
|
63 |
inputs, r"[!\"#$%&\(\)\*\+.,-/:;=?@\[\\\]^_`{|}~]?", ""
|
64 |
)
|
65 |
|
|
|
66 |
# Choose the most frequent words from the vocabulary & remove punctuation etc.
|
67 |
tokenizer = TextVectorization(
|
68 |
max_tokens=VOCAB_SIZE,
|
|
|
75 |
mask_token="", vocabulary=tokenizer.get_vocabulary()
|
76 |
)
|
77 |
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
## Probabilistic prediction using the trained model
|
80 |
def predict_caption(file):
|