Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +11 -7
- requirements.txt +1 -4
app.py
CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
|
|
2 |
import trafilatura
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
-
from
|
6 |
import requests
|
7 |
|
8 |
# File paths
|
@@ -26,12 +26,16 @@ def load_labels():
|
|
26 |
|
27 |
@st.cache_resource
|
28 |
def load_model():
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
|
36 |
def preprocess_text(text, vocab, max_length=128):
|
37 |
# Tokenize the text using the provided vocabulary
|
|
|
2 |
import trafilatura
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
+
from tflite_runtime.interpreter import Interpreter
|
6 |
import requests
|
7 |
|
8 |
# File paths
|
|
|
26 |
|
27 |
@st.cache_resource
|
28 |
def load_model():
|
29 |
+
try:
|
30 |
+
# Use TensorFlow Lite Interpreter
|
31 |
+
interpreter = Interpreter(model_path=MODEL_PATH)
|
32 |
+
interpreter.allocate_tensors()
|
33 |
+
input_details = interpreter.get_input_details()
|
34 |
+
output_details = interpreter.get_output_details()
|
35 |
+
return interpreter, input_details, output_details
|
36 |
+
except Exception as e:
|
37 |
+
st.error(f"Failed to load the model: {e}")
|
38 |
+
raise
|
39 |
|
40 |
def preprocess_text(text, vocab, max_length=128):
|
41 |
# Tokenize the text using the provided vocabulary
|
requirements.txt
CHANGED
@@ -3,7 +3,4 @@ trafilatura
|
|
3 |
numpy
|
4 |
pandas
|
5 |
requests
|
6 |
-
|
7 |
-
lxml
|
8 |
-
lxml_html_clean
|
9 |
-
|
|
|
3 |
numpy
|
4 |
pandas
|
5 |
requests
|
6 |
+
tflite-runtime
|
|
|
|
|
|