Update app.py
Browse files
app.py
CHANGED
@@ -22,41 +22,17 @@ import streamlit as st
|
|
22 |
import requests
|
23 |
import torch
|
24 |
from transformers import pipeline
|
|
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
-
url = f'https://drive.google.com/uc?export=download&id={file_id}'
|
29 |
-
response = requests.get(url, stream=True)
|
30 |
-
|
31 |
-
if response.status_code == 200:
|
32 |
-
with open(output_path, 'wb') as f:
|
33 |
-
for chunk in response.iter_content(chunk_size=8192):
|
34 |
-
if chunk:
|
35 |
-
f.write(chunk)
|
36 |
-
else:
|
37 |
-
raise Exception(f"Failed to download file: Status code {response.status_code}")
|
38 |
-
|
39 |
-
# Replace 'YOUR_FILE_ID' with the actual file ID of your model
|
40 |
-
file_id = '1A2B3C4D5E6F7G8H9I0J'
|
41 |
-
output_path = 'model.pt'
|
42 |
-
|
43 |
-
# Download the model file
|
44 |
-
try:
|
45 |
-
download_file_from_drive(file_id, output_path)
|
46 |
-
except Exception as e:
|
47 |
-
st.error(f"Error downloading file: {e}")
|
48 |
-
st.stop()
|
49 |
|
50 |
-
# Load the model
|
51 |
-
|
52 |
-
|
53 |
-
model.eval()
|
54 |
-
except Exception as e:
|
55 |
-
st.error(f"Error loading model: {e}")
|
56 |
-
st.stop()
|
57 |
|
58 |
# Initialize the summarization pipeline
|
59 |
-
summarizer = pipeline('summarization', model=model)
|
60 |
|
61 |
# Streamlit app layout
|
62 |
st.title("Text Summarization App")
|
|
|
22 |
import requests
|
23 |
import torch
|
24 |
from transformers import pipeline
|
25 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
26 |
|
27 |
+
# Replace with your Hugging Face model repository path
|
28 |
+
model_repo_path = 'AbdurRehman313/T5_samsum'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
# Load the model and tokenizer
|
31 |
+
model = T5ForConditionalGeneration.from_pretrained(model_repo_path)
|
32 |
+
tokenizer = T5Tokenizer.from_pretrained(model_repo_path)
|
|
|
|
|
|
|
|
|
33 |
|
34 |
# Initialize the summarization pipeline
|
35 |
+
summarizer = pipeline('summarization', model=model,tokenizer=tokenizer)
|
36 |
|
37 |
# Streamlit app layout
|
38 |
st.title("Text Summarization App")
|