Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +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_02')
|
6 |
|
7 |
def generate(text):
|
8 |
yt = pytube.YouTube(text)
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
return result[0]["generated_text"]
|
12 |
|
13 |
examples = [
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import pytube
|
3 |
+
from transformers import pipeline
|
4 |
+
from time import sleep
|
5 |
+
|
6 |
|
7 |
generator = pipeline('text-generation', model='parseny/youtube_comment_generation_02')
|
8 |
|
9 |
def generate(text):
|
10 |
yt = pytube.YouTube(text)
|
11 |
+
while True:
|
12 |
+
try:
|
13 |
+
title = yt.title
|
14 |
+
break
|
15 |
+
except:
|
16 |
+
sleep(1)
|
17 |
+
yt = pytube.YouTube(text)
|
18 |
+
continue
|
19 |
+
title = title.lower()
|
20 |
+
title = title.replace("[^a-zA-Z#]", " ")
|
21 |
+
title = title.replace(" +", " ")
|
22 |
+
prompt = f"Title: {title}\nComment:"
|
23 |
+
result = generator(prompt, max_new_tokens=30, num_return_sequences=1, do_sample=True)
|
24 |
return result[0]["generated_text"]
|
25 |
|
26 |
examples = [
|