victor commited on
Commit
425c345
Β·
1 Parent(s): 0b983db
app.py CHANGED
@@ -1,14 +1,11 @@
1
- import torch
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
 
3
 
4
- # Define the local model path
5
- model_path = "./review_analysis/output"
6
-
7
- # Load the tokenizer
8
- tokenizer = AutoTokenizer.from_pretrained(model_path)
9
 
10
- # Load the model directly from the local path
11
- model = AutoModelForSequenceClassification.from_pretrained(model_path)
12
 
13
  # Define the inference function
14
  def predict_sentiment(text):
@@ -19,7 +16,6 @@ def predict_sentiment(text):
19
  return label_map[predicted_label]
20
 
21
  # Gradio interface set-up
22
- import gradio as gr
23
  title = "Movie Review Sentiment Analysis"
24
  description = ("Enter a movie review and find out whether it's Positive or Negative!")
25
  review = gr.Textbox(lines=10, label="Enter your movie review here...")
 
1
+ import gradio as gr
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ import torch
4
 
5
+ #load model
6
+ model = AutoModelForSequenceClassification.from_pretrained("./")
7
+ tokenizer = AutoTokenizer.from_pretrained("./")
 
 
8
 
 
 
9
 
10
  # Define the inference function
11
  def predict_sentiment(text):
 
16
  return label_map[predicted_label]
17
 
18
  # Gradio interface set-up
 
19
  title = "Movie Review Sentiment Analysis"
20
  description = ("Enter a movie review and find out whether it's Positive or Negative!")
21
  review = gr.Textbox(lines=10, label="Enter your movie review here...")
output/config.json β†’ config.json RENAMED
File without changes
output/model.safetensors β†’ model.safetensors RENAMED
File without changes
output/special_tokens_map.json β†’ special_tokens_map.json RENAMED
File without changes
output/tokenizer.json β†’ tokenizer.json RENAMED
File without changes
output/tokenizer_config.json β†’ tokenizer_config.json RENAMED
File without changes
output/vocab.txt β†’ vocab.txt RENAMED
File without changes