marufc36 commited on
Commit
6a5e75e
·
1 Parent(s): 787d760
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import pipeline
4
+
5
+ device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
6
+
7
+ pipe = pipeline("text-generation", model="poem_generator2", device=device)
8
+
9
+ def generate_poem(text):
10
+ res = pipe(text)[0]["generated_text"]
11
+ return res
12
+
13
+ iface = gr.Interface(
14
+ generate_poem,
15
+ gr.Textbox(lines=5, label="Enter text to start the Poetic Lines"),
16
+ gr.Textbox(label="Generated Poetic Lines")
17
+ )
18
+
19
+ iface.launch()