Download app.py from kimda/asdasda: direct link, hf CLI and curl.
- Browser
- Download file 915 Bytes
-
https://huggingface.co/spaces/kimda/asdasda/resolve/main/app.py
- Command line
-
hf download hf://spaces/kimda/asdasda/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kimda/asdasda/resolve/main/app.py
915 Bytes
| import gradio as gr | |
| from transformers import PreTrainedTokenizerFast, BartForConditionalGeneration | |
| model_name = "ainize/kobart-news" | |
| tokenizer = PreTrainedTokenizerFast.from_pretrained(model_name) | |
| model = BartForConditionalGeneration.from_pretrained(model_name) | |
| # μλ¬Έμ λ°μμ μμ½λ¬Έμ λ°ν | |
| def summ(input_text): # λ§€κ°λ³μλͺ μ txtμμ input_textλ‘ λ³κ²½ | |
| input_ids = tokenizer.encode(input_text, return_tensors="pt") | |
| summary_text_ids = model.generate( | |
| input_ids=input_ids, | |
| bos_token_id=model.config.bos_token_id, | |
| eos_token_id=model.config.eos_token_id, | |
| length_penalty=2.0, | |
| max_length=142, | |
| min_length=56, | |
| num_beams=4) | |
| return tokenizer.decode(summary_text_ids[0], skip_special_tokens=True) | |
| interface = gr.Interface(summ, | |
| [gr.Textbox(label="original text")], | |
| [gr.Textbox(label="summary")]) | |
| interface.launch() |