Spaces:
Runtime error
Runtime error
Create app.py
Browse files
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()
|