vladyur commited on
Commit
d2e6254
1 Parent(s): aed615d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -20,7 +20,7 @@ def get_model(model_name, model_path):
20
 
21
 
22
  #@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, re.Pattern: lambda _: None}, allow_output_mutation=True, suppress_st_warning=True)
23
- def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, max_length=300):
24
  text += '\n'
25
  input_ids = tokenizer.encode(text, return_tensors="pt")
26
  length_of_prompt = len(input_ids[0])
@@ -30,7 +30,7 @@ def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, max_l
30
  num_beams=n_beams,
31
  temperature=temperature,
32
  top_p=top_p,
33
- max_length=max_length + length_of_prompt,
34
  eos_token_id=tokenizer.eos_token_id
35
  )
36
 
@@ -40,8 +40,7 @@ def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, max_l
40
  model, tokenizer = get_model('sberbank-ai/rugpt3medium_based_on_gpt2', 'korzh-medium_best_eval_loss.bin')
41
 
42
  # st.title("NeuroKorzh")
43
- # st.markdown("<img width=400px src='https://the-flow.ru/uploads/images/resize/830x0/adaptiveResize/05/06/06/42/25/8c7405840cd7.jpg'>",
44
- # unsafe_allow_html=True)
45
  image = Image.open('korzh.jpg')
46
  st.image(image, caption='NeuroKorzh')
47
 
@@ -63,7 +62,7 @@ if button:
63
  #lines = result.replace('\n', '\n\n')
64
  #st.write(lines)
65
 
66
- st.text_area(label='', value=result, height=400)
67
 
68
  #except Exception:
69
  # st.error("Ooooops, something went wrong. Try again please and report to me, tg: @vladyur")
 
20
 
21
 
22
  #@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, re.Pattern: lambda _: None}, allow_output_mutation=True, suppress_st_warning=True)
23
+ def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, length_of_generated=300):
24
  text += '\n'
25
  input_ids = tokenizer.encode(text, return_tensors="pt")
26
  length_of_prompt = len(input_ids[0])
 
30
  num_beams=n_beams,
31
  temperature=temperature,
32
  top_p=top_p,
33
+ max_length=length_of_prompt + length_of_generated,
34
  eos_token_id=tokenizer.eos_token_id
35
  )
36
 
 
40
  model, tokenizer = get_model('sberbank-ai/rugpt3medium_based_on_gpt2', 'korzh-medium_best_eval_loss.bin')
41
 
42
  # st.title("NeuroKorzh")
43
+
 
44
  image = Image.open('korzh.jpg')
45
  st.image(image, caption='NeuroKorzh')
46
 
 
62
  #lines = result.replace('\n', '\n\n')
63
  #st.write(lines)
64
 
65
+ st.text_area(label='', value=result, height=1200)
66
 
67
  #except Exception:
68
  # st.error("Ooooops, something went wrong. Try again please and report to me, tg: @vladyur")