muneebashraf commited on
Commit
6ba54d7
·
1 Parent(s): c0f01b6
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -29,14 +29,17 @@ def generate_caption_and_analyze_emotions(image):
29
  # Get the predicted emotion label
30
  emotion_label = emotion_tokenizer.decode(emotion_outputs.logits.argmax())
31
 
32
-
33
  # Prepare the final output with sentiment information
34
- #final_output = f"The sentiment in the provided image shows: {emotion_label}.\n\nGenerated Caption: {decoded_caption}"
35
- return emotion_label
36
 
37
  # Define the Gradio interface
38
  inputs = gr.inputs.Image(label="Upload an image")
39
- outputs = gr.outputs.Textbox(label="Generated Sentiment")
40
 
41
  # Create the Gradio app
42
- gr.Interface(fn=generate_caption_and_analyze_emotions, inputs=inputs, outputs=outputs).launch()
 
 
 
 
 
29
  # Get the predicted emotion label
30
  emotion_label = emotion_tokenizer.decode(emotion_outputs.logits.argmax())
31
 
 
32
  # Prepare the final output with sentiment information
33
+ final_output = f"The sentiment in the provided image shows: {emotion_label}.\n\nGenerated Caption: {decoded_caption}"
34
+ return final_output
35
 
36
  # Define the Gradio interface
37
  inputs = gr.inputs.Image(label="Upload an image")
38
+ outputs = gr.outputs.Textbox(label="Generated Caption and Sentiment Analysis")
39
 
40
  # Create the Gradio app
41
+ app = gr.Interface(fn=generate_caption_and_analyze_emotions, inputs=inputs, outputs=outputs)
42
+
43
+ # Launch the Gradio app
44
+ if __name__ == "__main__":
45
+ app.launch()