dejanseo commited on
Commit
38e96c5
·
verified ·
1 Parent(s): 78f6fe4

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +11 -7
  2. 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 ai_edge_litert.interpreter import Interpreter
6
  import requests
7
 
8
  # File paths
@@ -26,12 +26,16 @@ def load_labels():
26
 
27
  @st.cache_resource
28
  def load_model():
29
- # Load the LiteRT model
30
- interpreter = Interpreter(model_path=MODEL_PATH)
31
- interpreter.allocate_tensors()
32
- input_details = interpreter.get_input_details()
33
- output_details = interpreter.get_output_details()
34
- return interpreter, input_details, output_details
 
 
 
 
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
- ai-edge-litert
7
- lxml
8
- lxml_html_clean
9
-
 
3
  numpy
4
  pandas
5
  requests
6
+ tflite-runtime