dejanseo commited on
Commit
48e56e3
·
verified ·
1 Parent(s): e54d103

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -7,6 +7,13 @@ from io import BytesIO
7
  from bs4 import BeautifulSoup
8
  import pandas as pd
9
  import base64
 
 
 
 
 
 
 
10
 
11
  def load_model(model_path):
12
  interpreter = tf.lite.Interpreter(model_path=model_path)
@@ -50,7 +57,10 @@ def main():
50
  st.title("Shopping Intent Classification - SEO by DEJAN")
51
  st.write("Enter a URL to fetch and classify all images on the page. Javascript-based website scraping currently unsupported.")
52
 
 
53
  model_path = "model.tflite"
 
 
54
  url = st.text_input("Enter URL")
55
 
56
  if url:
 
7
  from bs4 import BeautifulSoup
8
  import pandas as pd
9
  import base64
10
+ import os
11
+
12
+ def download_model(model_url, model_path):
13
+ if not os.path.exists(model_path):
14
+ response = requests.get(model_url)
15
+ with open(model_path, 'wb') as f:
16
+ f.write(response.content)
17
 
18
  def load_model(model_path):
19
  interpreter = tf.lite.Interpreter(model_path=model_path)
 
57
  st.title("Shopping Intent Classification - SEO by DEJAN")
58
  st.write("Enter a URL to fetch and classify all images on the page. Javascript-based website scraping currently unsupported.")
59
 
60
+ model_url = "https://huggingface.co/dejanseo/shopping-intent/resolve/main/model.tflite"
61
  model_path = "model.tflite"
62
+ download_model(model_url, model_path)
63
+
64
  url = st.text_input("Enter URL")
65
 
66
  if url: