Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,6 +23,26 @@ def generate(prompt, system_prompt, max_new_tokens):
|
|
| 23 |
formatted_prompt = f" [INST] {system_prompt}, {prompt} [/INST]"
|
| 24 |
output = ""
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
for response in client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False):
|
| 27 |
output += response.token.text
|
| 28 |
|
|
@@ -51,7 +71,7 @@ def caption(img, min_len, max_len):
|
|
| 51 |
|
| 52 |
iface= gr.Interface(fn=caption,
|
| 53 |
title='Blip Image Captioning Large',
|
| 54 |
-
description="
|
| 55 |
inputs=[gr.Image(type='filepath', label='Image'), gr.Slider(label='Minimum Length', minimum=1, maximum=1000, value=30), gr.Slider(label='Maximum Length', minimum=1, maximum=1000, value=100)],
|
| 56 |
outputs=gr.Textbox(label='Caption'),
|
| 57 |
theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"),)
|
|
|
|
| 23 |
formatted_prompt = f" [INST] {system_prompt}, {prompt} [/INST]"
|
| 24 |
output = ""
|
| 25 |
|
| 26 |
+
for response in client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False):
|
| 27 |
+
output += response.token.text
|
| 28 |
+
|
| 29 |
+
return translate(output)
|
| 30 |
+
|
| 31 |
+
def translate(input):
|
| 32 |
+
generate_kwargs = dict(
|
| 33 |
+
temperature=0.7,
|
| 34 |
+
max_new_tokens=512,
|
| 35 |
+
top_p=0.95,
|
| 36 |
+
repetition_penalty=1.0,
|
| 37 |
+
do_sample=True,
|
| 38 |
+
seed=42,
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
system_prompt = "Traduza todo e qualquer texto que o usuário entregar para português."
|
| 42 |
+
|
| 43 |
+
formatted_prompt = f" [INST] {system_prompt}, {prompt} [/INST]"
|
| 44 |
+
output = ""
|
| 45 |
+
|
| 46 |
for response in client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False):
|
| 47 |
output += response.token.text
|
| 48 |
|
|
|
|
| 71 |
|
| 72 |
iface= gr.Interface(fn=caption,
|
| 73 |
title='Blip Image Captioning Large',
|
| 74 |
+
description="._.",
|
| 75 |
inputs=[gr.Image(type='filepath', label='Image'), gr.Slider(label='Minimum Length', minimum=1, maximum=1000, value=30), gr.Slider(label='Maximum Length', minimum=1, maximum=1000, value=100)],
|
| 76 |
outputs=gr.Textbox(label='Caption'),
|
| 77 |
theme = gr.themes.Base(primary_hue="teal",secondary_hue="teal",neutral_hue="slate"),)
|