Spaces:
Sleeping
Sleeping
Arturo Jiménez de los Galanes Reguillos
commited on
Commit
•
874ae6d
1
Parent(s):
4711fbe
Add progress bar
Browse files
app.py
CHANGED
@@ -30,12 +30,13 @@ decode_kwargs = dict(skip_special_tokens=True)
|
|
30 |
streamer = TextIteratorStreamer(tokenizer, decode_kwargs=decode_kwargs)
|
31 |
|
32 |
cplusplus = None
|
33 |
-
def translate(python):
|
|
|
34 |
inputs = tokenizer.apply_chat_template(
|
35 |
messages_for(python),
|
36 |
return_tensors="pt").to(model.device)
|
37 |
attention_mask = inputs["attention_mask"]
|
38 |
-
|
39 |
outputs = model.generate(
|
40 |
inputs,
|
41 |
attention_mask=attention_mask,
|
@@ -44,6 +45,7 @@ def translate(python):
|
|
44 |
pad_token_id=tokenizer.eos_token_id,
|
45 |
eos_token_id=tokenizer.eos_token_id,
|
46 |
)
|
|
|
47 |
return tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
|
48 |
'''
|
49 |
generation_kwargs = dict(
|
|
|
30 |
streamer = TextIteratorStreamer(tokenizer, decode_kwargs=decode_kwargs)
|
31 |
|
32 |
cplusplus = None
|
33 |
+
def translate(python, progress=gr.Progress()):
|
34 |
+
progress(0, desc="Starting")
|
35 |
inputs = tokenizer.apply_chat_template(
|
36 |
messages_for(python),
|
37 |
return_tensors="pt").to(model.device)
|
38 |
attention_mask = inputs["attention_mask"]
|
39 |
+
|
40 |
outputs = model.generate(
|
41 |
inputs,
|
42 |
attention_mask=attention_mask,
|
|
|
45 |
pad_token_id=tokenizer.eos_token_id,
|
46 |
eos_token_id=tokenizer.eos_token_id,
|
47 |
)
|
48 |
+
progress(1, desc="Finished")
|
49 |
return tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
|
50 |
'''
|
51 |
generation_kwargs = dict(
|