Spaces:
Runtime error
Runtime error
Download app.py from way2mhemanth/monish_script_summarizer: direct link, hf CLI and curl.
- Browser
- Download file 728 Bytes
-
https://huggingface.co/spaces/way2mhemanth/monish_script_summarizer/resolve/main/app.py
- Command line
-
hf download hf://spaces/way2mhemanth/monish_script_summarizer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/way2mhemanth/monish_script_summarizer/resolve/main/app.py
728 Bytes
| import gradio as gr | |
| import transformers | |
| from transformers import BartTokenizer, BartForConditionalGeneration | |
| model_name = 'facebook/bart-large-cnn' | |
| tokenizer = BartTokenizer.from_pretrained(model_name) | |
| model = BartForConditionalGeneration.from_pretrained(model_name) | |
| def summarize(inp): | |
| inp = inp.replace('\n','') | |
| inp = tokenizer.encode(inp, return_tensors='pt', max_length=1024) | |
| summary_ids = model.generate(inp, num_beams=4, max_length=1500, early_stopping=True) | |
| summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) | |
| return summary | |
| gr.Interface(fn=summarize, inputs=gr.inputs.Textbox(lines=7, label="Enter Your Scene"), outputs="text",title="Movie Script Summarizer").launch(inline=False) |