waqasali1707 commited on
Commit
5dc438c
·
verified ·
1 Parent(s): 55c9fb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -1,20 +1,14 @@
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,4 +36,4 @@ if text:
42
  st.write(output)
43
 
44
  except Exception as e:
45
- 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
 
5
+ # Define the URL of your model on Hugging Face Spaces
6
+ model_url = 'https://huggingface.co/your-username/your-model-name/resolve/main/'
 
 
 
 
 
7
 
8
+ # Load the model and tokenizer directly from the URL
9
  try:
10
+ tokenizer = AutoTokenizer.from_pretrained(model_url)
11
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_url)
12
  except Exception as e:
13
  st.error(f"Failed to load model: {e}")
14
 
 
36
  st.write(output)
37
 
38
  except Exception as e:
39
+ st.error(f"An error occurred during summarization: {e}")