parseny commited on
Commit
ccac9c6
1 Parent(s): 9e506d6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import pytube
4
+
5
+ generator = pipeline('text-generation', model='parseny/youtube_comment_generation')
6
+
7
+ def generate(text):
8
+ yt = pytube.YouTube(text)
9
+ title = f"Title: {yt.title.lower()}\nComment:"
10
+ result = generator(title, max_new_tokens=30, num_return_sequences=1, do_sample=True)
11
+ return result[0]["generated_text"]
12
+
13
+ examples = [
14
+ ["https://www.youtube.com/watch?v=mCV44C5rQ2M"],
15
+ ["https://www.youtube.com/watch?v=sitXeGjm4Mc"],
16
+ ["https://www.youtube.com/watch?v=oQS8KUoWL8E"],
17
+ ]
18
+
19
+ demo = gr.Interface(
20
+ fn=generate,
21
+ inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
22
+ outputs=gr.outputs.Textbox(label="Generated Text"),
23
+ examples=examples
24
+ )
25
+
26
+ demo.launch()