ctn8176 commited on
Commit
3b25749
1 Parent(s): 2ff483e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,7 +1,13 @@
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
7
  iface.launch()
 
1
+ import torch
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, TextGenerationPipeline
3
  import gradio as gr
4
 
5
+ model_name = "Writer/palmyra-small"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
+ model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
9
 
10
+ text_generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
11
+
12
+ iface = gr.Interface(fn=text_generator, inputs="text", outputs="text")
13
  iface.launch()