PlasmarineXD commited on
Commit
95ab416
·
1 Parent(s): 91ffa75

Add installation script to app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,11 +1,23 @@
1
- import streamlit as st
2
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  from transformers import AutoModel, AutoTokenizer
4
 
5
  # Access the Hugging Face token from environment variables
6
  hf_token = os.getenv('HUGGING_FACE_HUB_TOKEN')
7
 
8
- # Load the model and tokenizer with the token
9
  model = AutoModel.from_pretrained('naver/cocom-v1-128-mistral-7b', trust_remote_code=True, use_auth_token=hf_token)
10
  model = model.to('cuda')
11
  tokenizer = AutoTokenizer.from_pretrained('naver/cocom-v1-128-mistral-7b')
 
 
1
  import os
2
+ import subprocess
3
+
4
+ # Install dependencies if not present
5
+ def install(package):
6
+ subprocess.check_call([os.sys.executable, "-m", "pip", "install", package])
7
+
8
+ install("torch")
9
+ install("streamlit")
10
+ install("transformers")
11
+ install("flash-attn")
12
+
13
+ # Your existing imports and code
14
+ import streamlit as st
15
  from transformers import AutoModel, AutoTokenizer
16
 
17
  # Access the Hugging Face token from environment variables
18
  hf_token = os.getenv('HUGGING_FACE_HUB_TOKEN')
19
 
20
+ # Load the model and tokenizer with the token from environment variables
21
  model = AutoModel.from_pretrained('naver/cocom-v1-128-mistral-7b', trust_remote_code=True, use_auth_token=hf_token)
22
  model = model.to('cuda')
23
  tokenizer = AutoTokenizer.from_pretrained('naver/cocom-v1-128-mistral-7b')