muneebashraf commited on
Commit
2c9923d
·
1 Parent(s): 2c64837
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,5 +1,8 @@
1
  import gradio as gr
2
  from transformers import BlipProcessor, BlipForConditionalGeneration, RobertaTokenizer, RobertaForSequenceClassification
 
 
 
3
 
4
  # Load the image captioning model and tokenizer
5
  caption_model_name = "Salesforce/blip-image-captioning-large"
@@ -8,8 +11,8 @@ caption_model = BlipForConditionalGeneration.from_pretrained(caption_model_name)
8
 
9
  # Load the emotion analysis model and tokenizer
10
  emotion_model_name = "SamLowe/roberta-base-go_emotions"
11
- emotion_tokenizer = RobertaTokenizer.from_pretrained(emotion_model_name)
12
- emotion_model = RobertaForSequenceClassification.from_pretrained(emotion_model_name)
13
 
14
  def generate_caption_and_analyze_emotions(image):
15
  # Preprocess the image for caption generation
 
1
  import gradio as gr
2
  from transformers import BlipProcessor, BlipForConditionalGeneration, RobertaTokenizer, RobertaForSequenceClassification
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
+ import torch
5
+
6
 
7
  # Load the image captioning model and tokenizer
8
  caption_model_name = "Salesforce/blip-image-captioning-large"
 
11
 
12
  # Load the emotion analysis model and tokenizer
13
  emotion_model_name = "SamLowe/roberta-base-go_emotions"
14
+ emotion_tokenizer = AutoTokenizer.from_pretrained(emotion_model_name)
15
+ emotion_model = AutoModelForSequenceClassification.from_pretrained(emotion_model_name)
16
 
17
  def generate_caption_and_analyze_emotions(image):
18
  # Preprocess the image for caption generation