logu29 commited on
Commit
8505c64
·
verified ·
1 Parent(s): d1d98e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -6,14 +6,12 @@ import cv2
6
  import tempfile
7
  import os
8
 
9
- # Function to analyze text
10
  def analyze_text(text):
11
  blob = TextBlob(text)
12
  polarity = blob.sentiment.polarity
13
  sentiment = "Positive" if polarity > 0 else "Negative" if polarity < 0 else "Neutral"
14
- return f"Text Sentiment: {sentiment} (Polarity: {polarity:.2f})"
15
-
16
- # Function to analyze image (face emotion)
17
  def analyze_image(image):
18
  try:
19
  result = DeepFace.analyze(image, actions=['emotion'], enforce_detection=False)
@@ -21,8 +19,6 @@ def analyze_image(image):
21
  return f"Detected Emotion: {dominant_emotion}"
22
  except Exception as e:
23
  return f"Error: {str(e)}"
24
-
25
- # Function to analyze video (face emotion at center frame)
26
  def analyze_video(video_file):
27
  try:
28
  tmpdir = tempfile.mkdtemp()
@@ -36,7 +32,6 @@ def analyze_video(video_file):
36
  except Exception as e:
37
  return f"Error: {str(e)}"
38
 
39
- # Gradio UI
40
  with gr.Blocks() as demo:
41
  gr.Markdown("# 🧠 Emotion and Sentiment Analyzer")
42
  with gr.Tab("Text Analysis"):
 
6
  import tempfile
7
  import os
8
 
 
9
  def analyze_text(text):
10
  blob = TextBlob(text)
11
  polarity = blob.sentiment.polarity
12
  sentiment = "Positive" if polarity > 0 else "Negative" if polarity < 0 else "Neutral"
13
+ return f"Text Sentiment: {sentiment} (Polarity: {polarity:.2f}
14
+
 
15
  def analyze_image(image):
16
  try:
17
  result = DeepFace.analyze(image, actions=['emotion'], enforce_detection=False)
 
19
  return f"Detected Emotion: {dominant_emotion}"
20
  except Exception as e:
21
  return f"Error: {str(e)}"
 
 
22
  def analyze_video(video_file):
23
  try:
24
  tmpdir = tempfile.mkdtemp()
 
32
  except Exception as e:
33
  return f"Error: {str(e)}"
34
 
 
35
  with gr.Blocks() as demo:
36
  gr.Markdown("# 🧠 Emotion and Sentiment Analyzer")
37
  with gr.Tab("Text Analysis"):