Spaces:
Sleeping
Sleeping
name
commited on
Commit
·
3d9d95e
1
Parent(s):
2682483
stream
Browse files- app.py +6 -4
- requirements.txt +1 -1
app.py
CHANGED
@@ -20,11 +20,13 @@ def translate(inputs):
|
|
20 |
ids = tokenizer(inputs, max_length=512)
|
21 |
len_pad = 512 - len(ids)
|
22 |
if len_pad > 0:
|
23 |
-
ids = ids + [0 for x in range(len_pad)]
|
24 |
-
print(ids)
|
25 |
inputs = torch.tensor([ids]).to(torch.device('cpu'))
|
26 |
-
outputs = model.generate(inputs, max_length=512)
|
27 |
-
text =
|
|
|
|
|
|
|
28 |
return text
|
29 |
|
30 |
demo = gr.Interface(
|
|
|
20 |
ids = tokenizer(inputs, max_length=512)
|
21 |
len_pad = 512 - len(ids)
|
22 |
if len_pad > 0:
|
23 |
+
ids = ids + [0 for x in range(len_pad)]
|
|
|
24 |
inputs = torch.tensor([ids]).to(torch.device('cpu'))
|
25 |
+
outputs = model.generate(inputs, max_length=512, stream=True)
|
26 |
+
text = ''
|
27 |
+
for value in outputs:
|
28 |
+
text = tokenizer.ids2text(value.tolist()[0])
|
29 |
+
yield text
|
30 |
return text
|
31 |
|
32 |
demo = gr.Interface(
|
requirements.txt
CHANGED
@@ -2,4 +2,4 @@ transformers==4.36.2
|
|
2 |
sentencepiece==0.1.99
|
3 |
numpy==1.24.2
|
4 |
torch==2.0.1
|
5 |
-
-e git+https://github.com/t3ijk/tow.git@
|
|
|
2 |
sentencepiece==0.1.99
|
3 |
numpy==1.24.2
|
4 |
torch==2.0.1
|
5 |
+
-e git+https://github.com/t3ijk/tow.git@a797812b942e38d6c87dda6e5ff059b4b88e206f#egg=tow
|