zeyadusf commited on
Commit
357272e
1 Parent(s): 4ef7d17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
 
3
 
4
- # Load the model and tokenizer from Hugging Face Model Hub
5
- tokenizer = AutoTokenizer.from_pretrained("zeyadusf/FlanT5Summarization-samsum")
6
- model = AutoModelForSeq2SeqLM.from_pretrained("zeyadusf/FlanT5Summarization-samsum")
7
-
8
  def summarize(text):
9
  inputs = tokenizer(text, return_tensors="pt", truncation=True)
10
  summary_ids = model.generate(inputs.input_ids, max_length=512, min_length=64, length_penalty=2.0, num_beams=4, early_stopping=True)
 
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+ from peft import PeftModel, PeftConfig
4
 
5
+ config = PeftConfig.from_pretrained("zeyadusf/FlanT5Summarization-samsum")
6
+ base_model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-large")
7
+ model = PeftModel.from_pretrained(base_model, "zeyadusf/FlanT5Summarization-samsum")
 
8
  def summarize(text):
9
  inputs = tokenizer(text, return_tensors="pt", truncation=True)
10
  summary_ids = model.generate(inputs.input_ids, max_length=512, min_length=64, length_penalty=2.0, num_beams=4, early_stopping=True)