Imran1 commited on
Commit
f9f50dd
1 Parent(s): ed9c9be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -1,16 +1,18 @@
1
  from transformers import AutoTokenizer, AutoModelForCausalLM
2
  from transformers import pipeline
3
- tokenizer = AutoTokenizer.from_pretrained("Imran1/gpt2-urdu-news")
4
- model = AutoModelForCausalLM.from_pretrained("Imran1/gpt2-urdu-news")
5
- pipe = pipeline('text-generation',model=model, tokenizer=tokenizer)
 
 
6
 
7
 
8
  def text_generate(text):
9
- generate_text = pipe(f"{text}", max_length = 200,top_k=200, temperature=0.7, top_p=0.95)
10
  return generate_text[0]['generated_text']
11
 
12
 
13
- import gradio as gr
14
  exmp=["درمدی قیمتوں میں","ایک فیصلے میں کہا کہ"]
15
 
16
  gr.Interface(fn=text_generate, inputs="text", outputs="text", examples=exmp,title= "FINE TUNE GPT2 FOR URDU NEWS TEXT GENERATION").launch()
 
1
  from transformers import AutoTokenizer, AutoModelForCausalLM
2
  from transformers import pipeline
3
+ import gradio as gr
4
+
5
+ #tokenizer = AutoTokenizer.from_pretrained("Imran1/gpt2-urdu-news")
6
+ #model = AutoModelForCausalLM.from_pretrained("Imran1/gpt2-urdu-news")
7
+ pipe = pipeline('text-generation',"Imran1/gpt2-urdu-news")
8
 
9
 
10
  def text_generate(text):
11
+ generate_text = pipe(f"{text}", max_length = 200,top_k=2000, temperature=1.0, top_p=0.92)
12
  return generate_text[0]['generated_text']
13
 
14
 
15
+
16
  exmp=["درمدی قیمتوں میں","ایک فیصلے میں کہا کہ"]
17
 
18
  gr.Interface(fn=text_generate, inputs="text", outputs="text", examples=exmp,title= "FINE TUNE GPT2 FOR URDU NEWS TEXT GENERATION").launch()