azaninello commited on
Commit
3304da1
1 Parent(s): 4039b68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -1,24 +1,18 @@
1
  import gradio as gr
2
  import transformers
3
- from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline
4
  from transformers import GPT2Tokenizer, GPT2Model
5
 
6
- model = GPT2Model.from_pretrained('gpt2')
7
- tokenizer = GPT2Tokenizer.from_pretrained(
8
- 'gpt2',
9
- )
10
 
11
- generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('gpt2'),
12
- tokenizer='gpt2'#,
13
- #do_sample=True,
14
- #max_length=120,
15
- #top_k=50,
16
- #top_p=0.95,
17
- )
18
 
19
  def generator(start_your_text = ''):
20
- shroom_result = generator(start_your_text)
21
- return shroom_result[0]["generated_text"]
22
 
23
  iface = gr.Interface(fn=generator, inputs="text", outputs="text")
24
  iface.launch()
 
1
  import gradio as gr
2
  import transformers
3
+ from transformers import AutoModelForCausalLM, AutoModelWithLMHead, AutoTokenizer, pipeline
4
  from transformers import GPT2Tokenizer, GPT2Model
5
 
 
 
 
 
6
 
7
+ general_model = AutoModelForCausalLM.from_pretrained('gpt2')
8
+ general_generator = pipeline("text-generation", model=general_model, tokenizer="gpt2")
9
+ general_result = general_generator("Today is ", max_length=120)
10
+ general_result[0]["generated_text"]
11
+
 
 
12
 
13
  def generator(start_your_text = ''):
14
+ result = general_generator(start_your_text)
15
+ return result[0]["generated_text"]
16
 
17
  iface = gr.Interface(fn=generator, inputs="text", outputs="text")
18
  iface.launch()