Spaces:
Sleeping
Sleeping
Load Keras model and tokenizer from Hugging Face Hub in FastAPI application
Browse files
app.py
CHANGED
@@ -6,13 +6,17 @@ import tensorflow as tf
|
|
6 |
import joblib
|
7 |
import numpy as np
|
8 |
from huggingface_hub import hf_hub_download
|
9 |
-
import tensorflow as tf
|
10 |
-
import joblib
|
11 |
|
12 |
# Load the model and tokenizer from Hugging Face Hub
|
13 |
model_path = hf_hub_download(repo_id="rio3210/amharic-hate-speech-using-rnn-bidirectional", filename="amharic_hate_speech_rnn_model.keras")
|
14 |
tokenizer_path = hf_hub_download(repo_id="rio3210/amharic-hate-speech-using-rnn-bidirectional", filename="tokenizer.joblib")
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Define the FastAPI application
|
17 |
app = FastAPI()
|
18 |
|
|
|
6 |
import joblib
|
7 |
import numpy as np
|
8 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
9 |
|
10 |
# Load the model and tokenizer from Hugging Face Hub
|
11 |
model_path = hf_hub_download(repo_id="rio3210/amharic-hate-speech-using-rnn-bidirectional", filename="amharic_hate_speech_rnn_model.keras")
|
12 |
tokenizer_path = hf_hub_download(repo_id="rio3210/amharic-hate-speech-using-rnn-bidirectional", filename="tokenizer.joblib")
|
13 |
|
14 |
+
# Load the Keras model
|
15 |
+
keras_model = tf.keras.models.load_model(model_path)
|
16 |
+
|
17 |
+
# Load the tokenizer
|
18 |
+
tokenizer = joblib.load(tokenizer_path)
|
19 |
+
|
20 |
# Define the FastAPI application
|
21 |
app = FastAPI()
|
22 |
|