Spaces:
Sleeping
Sleeping
| import os | |
| import gradio as gr | |
| from transformers import pipeline | |
| # 1. Get the secret token you just saved | |
| hf_token = os.getenv("HF_TOKEN") | |
| # 2. Load the model WITH the token | |
| # The 'token' argument proves you have permission to access the private model | |
| pipe = pipeline( | |
| "summarization", | |
| model="jrsenobio/summarizer_model", | |
| token=hf_token | |
| ) | |
| def summarize(text): | |
| if not text: | |
| return "No text provided" | |
| # Run the model | |
| output = pipe(text, max_length=130, min_length=30) | |
| return output[0]['summary_text'] | |
| demo = gr.Interface( | |
| fn=summarize, | |
| inputs="text", | |
| outputs="text" | |
| ) | |
| demo.launch() | |