Hadeel11 commited on
Commit
0797b92
1 Parent(s): 514a533

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM, TextGenerationPipeline
2
+ from gradio import Interface
3
+
4
+ model_name = "Hadeel11/fine-tuned-model-2"
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+
10
+ model.half()
11
+
12
+ text_generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
13
+
14
+ def generate_text(prompt):
15
+ return text_generator(prompt, max_length=512, num_return_sequences=1)[0]['generated_text']
16
+
17
+ iface = Interface(fn=generate_text, inputs="text", outputs="text", title="Text Generation Inference")
18
+
19
+ iface.launch()