Imran1 commited on
Commit
b38350f
1 Parent(s): 52df1c1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()