jarif commited on
Commit
4961115
1 Parent(s): 0f97217

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -1,21 +1,22 @@
1
- import gradio as gr
2
  from fastai.text.all import *
3
  from blurr.text.data.all import *
4
- from blurr.text.modeling.all import *
5
- from transformers import T5Tokenizer, T5ForConditionalGeneration
6
- from transformers import BartForConditionalGeneration
7
 
8
- # Load the pre-trained model and tokenizer
9
- pretrained_model_name = "facebook/bart-large-cnn"
10
  hf_tokenizer = T5Tokenizer.from_pretrained(pretrained_model_name)
11
- learn = load_learner('article_highlights.pkl')
12
 
13
  def summarize(article):
14
- # Preprocess the input text
15
- processed_text = learn.dblock.pipeline(article)
 
 
 
16
 
17
  # Generate the summary
18
- summary = learn.predict(processed_text)[0]['highlights']
19
 
20
  return summary
21
 
 
1
+ import torch
2
  from fastai.text.all import *
3
  from blurr.text.data.all import *
4
+ from blurr.text.modeling.all import * # Import only needed functions
5
+ from transformers import T5Tokenizer, T5ForConditionalGeneration # Use T5 specifically
 
6
 
7
+ # Load the pre-trained model and tokenizer (adjust for Bart if needed)
8
+ pretrained_model_name = "facebook/bart-large-cnn" # Or "facebook/bart-base"
9
  hf_tokenizer = T5Tokenizer.from_pretrained(pretrained_model_name)
 
10
 
11
  def summarize(article):
12
+ # Define your data transformation pipeline here, if applicable
13
+ # ...
14
+
15
+ # Load the exported model
16
+ learn = load_learner('article_highlights.pkl')
17
 
18
  # Generate the summary
19
+ summary = learn.predict(article)[0]['highlights']
20
 
21
  return summary
22