dejanseo commited on
Commit
767039c
·
verified ·
1 Parent(s): afce47c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -1,24 +1,23 @@
1
  import streamlit as st
2
  import torch
3
- from transformers import AlbertTokenizer, AlbertForSequenceClassification, AlbertConfig
4
  import plotly.graph_objects as go
5
 
6
  # URL of the logo
7
  logo_url = "https://dejan.ai/wp-content/uploads/2024/02/dejan-300x103.png"
8
 
9
- # Display the logo at the top using st.logo
10
- st.logo(logo_url, link="https://dejan.ai")
11
 
12
  # Streamlit app title and description
13
- st.title("Search Query Form Classifier")
14
- st.write("Ambiguous search queries are candidates for query expansion. Our model identifies such queries with an 80 percent accuracy and is deployed in a batch processing pipeline directly connected with Google Search Console API. In this demo you can test the model capability by testing individual queries.")
15
  st.write("Enter a query to check if it's well-formed:")
 
16
 
17
- # Load the model and tokenizer from the /model/ directory
18
- model_dir = 'model'
19
- tokenizer = AlbertTokenizer.from_pretrained(model_dir)
20
- config = AlbertConfig.from_pretrained(model_dir)
21
- model = AlbertForSequenceClassification.from_pretrained(model_dir, config=config)
22
 
23
  # Set the model to evaluation mode
24
  model.eval()
@@ -26,8 +25,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
26
  model.to(device)
27
 
28
  # User input
29
- user_input = st.text_input("Query:", "What is?")
30
- st.write("Developed by [Dejan AI](https://dejan.ai/blog/search-query-quality-classifier/)")
31
 
32
  def classify_query(query):
33
  # Tokenize input
 
1
  import streamlit as st
2
  import torch
3
+ from transformers import AlbertTokenizer, AlbertForSequenceClassification, AutoModelForSequenceClassification, AutoTokenizer
4
  import plotly.graph_objects as go
5
 
6
  # URL of the logo
7
  logo_url = "https://dejan.ai/wp-content/uploads/2024/02/dejan-300x103.png"
8
 
9
+ # Display the logo at the top using st.image
10
+ st.image(logo_url, use_column_width=True)
11
 
12
  # Streamlit app title and description
13
+ st.title("DEJAN AI Search Query Classifier")
 
14
  st.write("Enter a query to check if it's well-formed:")
15
+ st.write("See [Dejan AI](https://dejan.ai/blog/search-query-quality-classifier/)")
16
 
17
+ # Load the model and tokenizer from Hugging Face Hub
18
+ model_name = 'dejanseo/Query-Quality-Classifier'
19
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
20
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
 
21
 
22
  # Set the model to evaluation mode
23
  model.eval()
 
25
  model.to(device)
26
 
27
  # User input
28
+ user_input = st.text_input("Query:")
 
29
 
30
  def classify_query(query):
31
  # Tokenize input