Spaces:
Runtime error
Runtime error
ai-forever
commited on
Commit
·
84ff7f1
1
Parent(s):
9db38b1
Update app.py
Browse files
app.py
CHANGED
@@ -26,13 +26,14 @@ fp16 = device != 'cpu'
|
|
26 |
def transl(text, src='en', dest='hy' ):
|
27 |
return translator.translate(text, src=src, dest=dest).text
|
28 |
|
29 |
-
def generate(prompt: str
|
30 |
-
print(prompt)
|
31 |
-
print(length, type(length))
|
|
|
32 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
33 |
out = model.generate(input_ids,
|
34 |
-
min_length=
|
35 |
-
max_length=
|
36 |
top_p=0.95,
|
37 |
top_k=0,
|
38 |
temperature=0.9,
|
@@ -41,15 +42,16 @@ def generate(prompt: str, length=500):
|
|
41 |
generated_text = list(map(tokenizer.decode, out))[0]
|
42 |
return generated_text #+ '\n\n'+transl(generated_text, src='hy', dest='en')
|
43 |
|
44 |
-
length = gr.inputs.Slider(200, 1000)
|
45 |
|
46 |
-
|
|
|
|
|
47 |
|
48 |
interface = gr.Interface.load("huggingface/sberbank-ai/mGPT-armenian",
|
49 |
description=description,
|
50 |
examples=examples,
|
51 |
fn=generate,
|
52 |
-
inputs=[contexto,length],#
|
53 |
outputs='text',
|
54 |
thumbnail = 'https://habrastorage.org/r/w1560/getpro/habr/upload_files/26a/fa1/3e1/26afa13e1d1a56f54c7b0356761af7b8.png',
|
55 |
theme = "peach",
|
|
|
26 |
def transl(text, src='en', dest='hy' ):
|
27 |
return translator.translate(text, src=src, dest=dest).text
|
28 |
|
29 |
+
def generate(prompt: str):
|
30 |
+
#print(prompt)
|
31 |
+
#print(length, type(length))
|
32 |
+
length = int(length)
|
33 |
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
34 |
out = model.generate(input_ids,
|
35 |
+
min_length=500,
|
36 |
+
max_length=1000,
|
37 |
top_p=0.95,
|
38 |
top_k=0,
|
39 |
temperature=0.9,
|
|
|
42 |
generated_text = list(map(tokenizer.decode, out))[0]
|
43 |
return generated_text #+ '\n\n'+transl(generated_text, src='hy', dest='en')
|
44 |
|
|
|
45 |
|
46 |
+
|
47 |
+
#contexto = gr.inputs.Textbox(lines=10, placeholder="Write your text here")
|
48 |
+
#length = gr.inputs.Slider(200, 1000)
|
49 |
|
50 |
interface = gr.Interface.load("huggingface/sberbank-ai/mGPT-armenian",
|
51 |
description=description,
|
52 |
examples=examples,
|
53 |
fn=generate,
|
54 |
+
inputs="text",#[contexto,length],#
|
55 |
outputs='text',
|
56 |
thumbnail = 'https://habrastorage.org/r/w1560/getpro/habr/upload_files/26a/fa1/3e1/26afa13e1d1a56f54c7b0356761af7b8.png',
|
57 |
theme = "peach",
|