talha2001 commited on
Commit
2b4e0ed
·
verified ·
1 Parent(s): 1370031

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -1,25 +1,14 @@
1
  import streamlit as st
2
  from transformers import T5Tokenizer, T5ForConditionalGeneration
3
  import torch
4
- import gdown
5
  import os
6
 
7
- # Function to download and extract the model from Google Drive
8
- @st.cache_resource
9
- def download_and_load_model():
10
- url = 'https://drive.google.com/uc?id=YOUR_FILE_ID' # Replace with your actual file ID
11
- output = 'T5_samsum.zip'
12
- model_path = './T5_samsum'
13
 
14
- if not os.path.exists(model_path):
15
- gdown.download(url, output, quiet=False)
16
- os.system(f"unzip {output} -d {model_path}")
17
-
18
- model = T5ForConditionalGeneration.from_pretrained(model_path)
19
- tokenizer = T5Tokenizer.from_pretrained(model_path)
20
- return model, tokenizer
21
-
22
- model, tokenizer = download_and_load_model()
23
 
24
  st.title("T5 Summarization")
25
 
 
1
  import streamlit as st
2
  from transformers import T5Tokenizer, T5ForConditionalGeneration
3
  import torch
 
4
  import os
5
 
6
+ # Path to the folder containing the saved model
7
+ model_path = './T5_samsum'
 
 
 
 
8
 
9
+ # Ensure the model and tokenizer are loaded from the specified folder
10
+ model = T5ForConditionalGeneration.from_pretrained(model_path)
11
+ tokenizer = T5Tokenizer.from_pretrained(model_path)
 
 
 
 
 
 
12
 
13
  st.title("T5 Summarization")
14