Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -64,11 +64,7 @@ emotion_prediction_tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/di
|
|
64 |
response_model_name = "gpt2-xl"
|
65 |
response_tokenizer = AutoTokenizer.from_pretrained(response_model_name)
|
66 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
67 |
-
|
68 |
-
with init_empty_weights():
|
69 |
-
response_model = AutoModelForCausalLM.from_pretrained(response_model_name)
|
70 |
-
response_model.tie_weights()
|
71 |
-
response_model.to(device)
|
72 |
|
73 |
# Set the pad token
|
74 |
response_tokenizer.pad_token = response_tokenizer.eos_token
|
@@ -102,6 +98,7 @@ def save_historical_data(historical_data, file_path=emotion_history_file):
|
|
102 |
|
103 |
emotion_history = load_historical_data()
|
104 |
|
|
|
105 |
def update_emotion(emotion, percentage, intensity):
|
106 |
emotions[emotion]['percentage'] += percentage
|
107 |
emotions[emotion]['intensity'] = intensity
|
|
|
64 |
response_model_name = "gpt2-xl"
|
65 |
response_tokenizer = AutoTokenizer.from_pretrained(response_model_name)
|
66 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
67 |
+
response_model = load_checkpoint_and_dispatch(AutoModelForCausalLM, response_model_name, device_map="auto")
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# Set the pad token
|
70 |
response_tokenizer.pad_token = response_tokenizer.eos_token
|
|
|
98 |
|
99 |
emotion_history = load_historical_data()
|
100 |
|
101 |
+
|
102 |
def update_emotion(emotion, percentage, intensity):
|
103 |
emotions[emotion]['percentage'] += percentage
|
104 |
emotions[emotion]['intensity'] = intensity
|