Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,20 @@
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, GenerationConfig
|
|
|
|
|
4 |
|
5 |
-
#
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
# Load the model and tokenizer directly from the URL
|
9 |
try:
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
11 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(
|
12 |
except Exception as e:
|
13 |
st.error(f"Failed to load model: {e}")
|
14 |
|
@@ -36,4 +42,4 @@ if text:
|
|
36 |
st.write(output)
|
37 |
|
38 |
except Exception as e:
|
39 |
-
st.error(f"An error occurred during summarization: {e}")
|
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, GenerationConfig
|
4 |
+
from pydrive2.auth import GoogleAuth
|
5 |
+
from pydrive2.drive import GoogleDrive
|
6 |
|
7 |
+
# Authenticate and create the PyDrive client.
|
8 |
+
gauth = GoogleAuth()
|
9 |
+
gauth.LocalWebserverAuth() # Creates a local webserver and automatically handles authentication.
|
10 |
+
drive = GoogleDrive(gauth)
|
11 |
+
|
12 |
+
# Update this path to your local path where the model is stored
|
13 |
+
model_path = '/content/drive/My Drive/bart-base'
|
14 |
|
|
|
15 |
try:
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
17 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
18 |
except Exception as e:
|
19 |
st.error(f"Failed to load model: {e}")
|
20 |
|
|
|
42 |
st.write(output)
|
43 |
|
44 |
except Exception as e:
|
45 |
+
st.error(f"An error occurred during summarization: {e}")
|