Spaces:
Sleeping
Sleeping
okeowo1014
commited on
Commit
•
416195d
1
Parent(s):
1990fd1
Update tr.py
Browse files
tr.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import numpy as np
|
2 |
import tensorflow as tf
|
3 |
from tensorflow.keras.models import Sequential
|
@@ -6,6 +7,9 @@ from tensorflow.keras.preprocessing.text import Tokenizer
|
|
6 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
7 |
from sklearn.model_selection import train_test_split
|
8 |
|
|
|
|
|
|
|
9 |
# Sample data for sentiment analysis
|
10 |
texts = ["I love deep learning!", "I hate Mondays.", "This movie is fantastic.", "The weather is terrible."]
|
11 |
labels = np.array([1, 0, 1, 0]) # 1 for positive sentiment, 0 for negative sentiment
|
@@ -48,3 +52,11 @@ sequences = tokenizer.texts_to_sequences(new_texts)
|
|
48 |
padded_sequences = pad_sequences(sequences, maxlen=10, padding='post', truncating='post')
|
49 |
predictions = loaded_model.predict(padded_sequences)
|
50 |
print(predictions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import numpy as np
|
3 |
import tensorflow as tf
|
4 |
from tensorflow.keras.models import Sequential
|
|
|
7 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
8 |
from sklearn.model_selection import train_test_split
|
9 |
|
10 |
+
# Environment variable for Hugging Face token
|
11 |
+
sac = os.getenv('accesstoken')
|
12 |
+
|
13 |
# Sample data for sentiment analysis
|
14 |
texts = ["I love deep learning!", "I hate Mondays.", "This movie is fantastic.", "The weather is terrible."]
|
15 |
labels = np.array([1, 0, 1, 0]) # 1 for positive sentiment, 0 for negative sentiment
|
|
|
52 |
padded_sequences = pad_sequences(sequences, maxlen=10, padding='post', truncating='post')
|
53 |
predictions = loaded_model.predict(padded_sequences)
|
54 |
print(predictions)
|
55 |
+
|
56 |
+
push_to_hub_keras(
|
57 |
+
model,
|
58 |
+
repo_name="okeowo1014/kerascatanddog",
|
59 |
+
model_id="my_custom_text_classifier",
|
60 |
+
commit_message="Initial commit",
|
61 |
+
token=sac
|
62 |
+
)
|