Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
sentiment_string = ''.join(str(e) for e in sentiment)
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
|