Spaces:
Sleeping
Sleeping
| #I used the https://www.marqo.ai/blog/how-to-create-a-hugging-face-space to help make this code. | |
| #Logan Lin, Period 3, Artificial Intelligence, | |
| import gradio as gr | |
| from transformers import AutoModel, AutoProcessor | |
| import torch | |
| import requests | |
| from PIL import Image | |
| from io import BytesIO | |
| from transformers import pipeline | |
| import torch | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| def summarize_text(input_text): | |
| if not input_text.strip(): | |
| return {"Error": "Please input some text"} | |
| summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False) | |
| return summary[0]['summary_text'] | |
| demo = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(label="Enter Text to Summarize", lines=5), | |
| outputs=gr.Label(label="Summary"), | |
| title="Text Summarization", | |
| description="This app uses the facebook/bart-large-cnn for summarizing input and the code is made my Logan Lin.", | |
| allow_flagging="never" | |
| ) | |
| demo.launch() |