Spaces:
Paused
Paused
File size: 1,652 Bytes
9e5c5bb 7d93f13 e91f2c0 9e5c5bb 0f7e2c9 9e5c5bb e91f2c0 f2a8b90 7d93f13 e91f2c0 7d93f13 d48a51a e91f2c0 17409ce e91f2c0 7d93f13 17409ce 152a7cc d48a51a 9e5c5bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import re
from transformers import AutoTokenizer, AutoModel
MODEL_NAME = "silver/chatglm-6b-slim"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
model = AutoModel.from_pretrained(MODEL_NAME, trust_remote_code=True)
def summarize(transcript, sentence_count):
history = []
prompt = f"""视频脚本:{transcript}。我希望你作为一名专业的视频内容编辑,帮我用中文总结视频脚本的内容精华。请先用一句简短的话总结视频梗概。然后再请你将视频字幕文本进行总结(字幕中可能有错别字,如果你发现了错别字请改正)。请你以无序列表的方式返回,请注意不要超过{sentence_count}条哦,确保所有的句子都足够精简,清晰完整,祝你好运!"""
response, history = model.chat(tokenizer, prompt, history=history)
return response
demo = gr.Interface(fn = summarize,
inputs = [gr.Textbox(lines=10,
placeholder="Input something...",
label='Text here !!'),
gr.Slider(minimum=1,
maximum=10,
step=1,
label='Sentence Count')],
outputs = [gr.Textbox(lines=10,
label="Summary")],
title = "🎈 Summarizer 🎈")
demo.launch() |