ai-forever commited on
Commit
031192b
1 Parent(s): 74e721c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -26,11 +26,11 @@ 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
  input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
31
  out = model.generate(input_ids,
32
- min_length=300,
33
- max_length=700,
34
  top_p=0.95,
35
  top_k=0,
36
  temperature=0.9,
@@ -40,13 +40,14 @@ def generate(prompt: str):
40
  return generated_text #+ '\n\n'+transl(generated_text, src='hy', dest='en')
41
 
42
  length = gr.inputs.Slider(200, 1000)
 
43
  contexto = gr.inputs.Textbox(lines=10, placeholder="Write your text here")
44
 
45
  interface = gr.Interface.load("huggingface/sberbank-ai/mGPT-armenian",
46
  description=description,
47
  examples=examples,
48
  fn=generate,
49
- inputs=inputs=[contexto,length],#"text",
50
  outputs='text',
51
  thumbnail = 'https://habrastorage.org/r/w1560/getpro/habr/upload_files/26a/fa1/3e1/26afa13e1d1a56f54c7b0356761af7b8.png',
52
  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, length=500):
30
  input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
31
  out = model.generate(input_ids,
32
+ min_length=length,
33
+ max_length=length,
34
  top_p=0.95,
35
  top_k=0,
36
  temperature=0.9,
 
40
  return generated_text #+ '\n\n'+transl(generated_text, src='hy', dest='en')
41
 
42
  length = gr.inputs.Slider(200, 1000)
43
+
44
  contexto = gr.inputs.Textbox(lines=10, placeholder="Write your text here")
45
 
46
  interface = gr.Interface.load("huggingface/sberbank-ai/mGPT-armenian",
47
  description=description,
48
  examples=examples,
49
  fn=generate,
50
+ inputs=[contexto,length],#"text",
51
  outputs='text',
52
  thumbnail = 'https://habrastorage.org/r/w1560/getpro/habr/upload_files/26a/fa1/3e1/26afa13e1d1a56f54c7b0356761af7b8.png',
53
  theme = "peach",