iimran commited on
Commit
16ab585
·
verified ·
1 Parent(s): 6d7bc3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,12 +1,14 @@
1
  import gradio as gr
2
  from transformers import BartTokenizer, BartForConditionalGeneration
 
 
 
3
 
4
  # Load model and tokenizer from Hugging Face hub using the provided model name
5
  model_name = "iimran/SAM-TheSummariserV2"
6
- tokenizer = BartTokenizer.from_pretrained(model_name)
7
- model = BartForConditionalGeneration.from_pretrained(model_name)
8
 
9
- # Define the summarization function
10
  def summarize(input_text):
11
  # Tokenize the input text with truncation
12
  inputs = tokenizer(input_text, max_length=1024, truncation=True, return_tensors="pt")
 
1
  import gradio as gr
2
  from transformers import BartTokenizer, BartForConditionalGeneration
3
+ hf_token = os.getenv("HF_TOKEN")
4
+ if hf_token is None:
5
+ raise ValueError("HF_TOKEN environment variable is not set.")
6
 
7
  # Load model and tokenizer from Hugging Face hub using the provided model name
8
  model_name = "iimran/SAM-TheSummariserV2"
9
+ tokenizer = BartTokenizer.from_pretrained(model_name, use_auth_token=hf_token)
10
+ model = BartForConditionalGeneration.from_pretrained(model_name, use_auth_token=hf_token)
11
 
 
12
  def summarize(input_text):
13
  # Tokenize the input text with truncation
14
  inputs = tokenizer(input_text, max_length=1024, truncation=True, return_tensors="pt")