serhii-korobchenko commited on
Commit
0fd72b0
1 Parent(s): 8f24074

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -13,7 +13,7 @@ def download_model_NLP():
13
  model = keras_nlp.models.GPT2CausalLM.from_preset(
14
  "gpt2_base_en", preprocessor=preprocessor)
15
 
16
-
17
  #output = "GPT2_keras_deer"
18
  #id_weights = "106fk9vGF_sHB8St9B2cKYE9jQVNSdKW_"
19
  #gdown.download(id=id_weights, output=output, quiet=False)
@@ -38,18 +38,19 @@ def download_model_NLP():
38
  model.load_weights(output)
39
  #model = tf.keras.models.load_model(output)
40
 
41
- return model
42
 
43
 
44
  def get_model():
45
  return pipeline('text-generation', model='gpt-2')
46
 
47
  def complete_text(start_of_sentence):
48
-
 
49
  result = model.generate(start_of_sentence, max_length=100)
50
  #result = model(start_of_sentence, max_length=50, do_sample=True)[0]['generated_text']
51
  return result
52
 
53
- model = download_model_NLP()
54
- iface = gr.Interface(fn=complete_text, inputs=gr.inputs.Textbox(lines=2, placeholder='Start of Sentence Here...'), outputs="text")
55
  iface.launch()
 
13
  model = keras_nlp.models.GPT2CausalLM.from_preset(
14
  "gpt2_base_en", preprocessor=preprocessor)
15
 
16
+ model_clear = model
17
  #output = "GPT2_keras_deer"
18
  #id_weights = "106fk9vGF_sHB8St9B2cKYE9jQVNSdKW_"
19
  #gdown.download(id=id_weights, output=output, quiet=False)
 
38
  model.load_weights(output)
39
  #model = tf.keras.models.load_model(output)
40
 
41
+ return model_clear, model
42
 
43
 
44
  def get_model():
45
  return pipeline('text-generation', model='gpt-2')
46
 
47
  def complete_text(start_of_sentence):
48
+
49
+ result_clear = model_clear.generate(start_of_sentence, max_length=100)
50
  result = model.generate(start_of_sentence, max_length=100)
51
  #result = model(start_of_sentence, max_length=50, do_sample=True)[0]['generated_text']
52
  return result
53
 
54
+ model_clear, model = download_model_NLP()
55
+ iface = gr.Interface(fn=complete_text, inputs=gr.inputs.Textbox(lines=2, placeholder='Start of Sentence Here...'), outputs=["text", "text"],)
56
  iface.launch()