Spaces:
Running
on
T4
Running
on
T4
praeclarumjj3
commited on
Commit
·
88d40e8
1
Parent(s):
43d0bad
Compile Worked, fix path data
Browse files
oneformer/data/tokenizer.py
CHANGED
@@ -24,8 +24,9 @@
|
|
24 |
# Modified by Jiarui Xu
|
25 |
# -------------------------------------------------------------------------
|
26 |
|
27 |
-
from StringIO import StringIO
|
28 |
-
from urllib import urlopen
|
|
|
29 |
import gzip
|
30 |
import html
|
31 |
import os
|
@@ -39,9 +40,10 @@ import torch
|
|
39 |
@lru_cache()
|
40 |
def default_bpe():
|
41 |
url = 'https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/data/bpe_simple_vocab_16e6.txt.gz'
|
42 |
-
|
43 |
-
|
44 |
-
# return
|
|
|
45 |
|
46 |
|
47 |
@lru_cache()
|
@@ -128,7 +130,7 @@ class SimpleTokenizer(object):
|
|
128 |
self.byte_encoder = bytes_to_unicode()
|
129 |
self.byte_decoder = {v: k for k, v in self.byte_encoder.items()}
|
130 |
|
131 |
-
merges = gzip.GzipFile(fileobj=bpe_path, mode='rb')
|
132 |
|
133 |
merges = gzip.open(bpe_path).read().decode('utf-8').split('\n')
|
134 |
merges = merges[1:49152 - 256 - 2 + 1]
|
|
|
24 |
# Modified by Jiarui Xu
|
25 |
# -------------------------------------------------------------------------
|
26 |
|
27 |
+
# from StringIO import StringIO
|
28 |
+
# from urllib import urlopen
|
29 |
+
import wget
|
30 |
import gzip
|
31 |
import html
|
32 |
import os
|
|
|
40 |
@lru_cache()
|
41 |
def default_bpe():
|
42 |
url = 'https://github.com/SHI-Labs/OneFormer/blob/main/oneformer/data/bpe_simple_vocab_16e6.txt.gz'
|
43 |
+
wget.download(url, os.path.dirname(os.path.abspath(__file__)))
|
44 |
+
# inmemory = StringIO(urlopen(url).read())
|
45 |
+
# return inmemory
|
46 |
+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bpe_simple_vocab_16e6.txt.gz')
|
47 |
|
48 |
|
49 |
@lru_cache()
|
|
|
130 |
self.byte_encoder = bytes_to_unicode()
|
131 |
self.byte_decoder = {v: k for k, v in self.byte_encoder.items()}
|
132 |
|
133 |
+
# merges = gzip.GzipFile(fileobj=bpe_path, mode='rb')
|
134 |
|
135 |
merges = gzip.open(bpe_path).read().decode('utf-8').split('\n')
|
136 |
merges = merges[1:49152 - 256 - 2 + 1]
|