suryabbrj commited on
Commit
6e993f7
1 Parent(s): 8ae1366

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -6,7 +6,6 @@ warnings.simplefilter('ignore')
6
  logging.disable(logging.WARNING)
7
 
8
 
9
-
10
  def predict(image):
11
  cap = pipeline('image-to-text')
12
  caption = cap(image)
@@ -16,15 +15,22 @@ def predict(image):
16
  pipe = pipeline('text-classification')
17
  senti = pipe(shortened)
18
  return senti
 
19
  caption_string = str(caption)
20
- shortened = caption_string[21:-3]
21
- formatted_capt = caption_string.replace("[{'generated_text': '" , "The image is of, ")
22
- formatted_capt = formatted_capt.replace("'}]" , "")
23
- sentiment = sentiment_analysis(shortened)
 
24
  sentiment_string = ''.join(str(e) for e in sentiment)
25
- formated_senti = sentiment_string.replace("{'label': ", ", The Tone of the image(sentiment) after analysisng the caption is that is it is ")
26
- formated_senti = formated_senti.replace("'score': ", "in nature with an average percentage of ")
27
- output = formatted_capt + formated_senti[0:-2] + '%'
 
 
 
 
 
28
  return output
29
 
30
 
 
6
  logging.disable(logging.WARNING)
7
 
8
 
 
9
  def predict(image):
10
  cap = pipeline('image-to-text')
11
  caption = cap(image)
 
15
  pipe = pipeline('text-classification')
16
  senti = pipe(shortened)
17
  return senti
18
+
19
  caption_string = str(caption)
20
+
21
+ sentiment = sentiment_analysis(caption_string[21:-1])
22
+
23
+
24
+
25
  sentiment_string = ''.join(str(e) for e in sentiment)
26
+
27
+ formatted_cap = caption_string.replace("[{'generated_text': '" , "the image is of, ")
28
+
29
+ formated_senti = sentiment_string.replace("{'label': ", ", The Tone of the image is mostly ")
30
+
31
+ formated_senti = formated_senti.replace("score': ", " with approx : ")
32
+
33
+ output = formatted_cap + formated_senti[1:-15] + '% score'
34
  return output
35
 
36