Spaces:
Runtime error
Runtime error
File size: 883 Bytes
1ed7018 f0a9d5d 1ed7018 f0a9d5d 1ed7018 f0a9d5d 1ed7018 f0a9d5d 1ed7018 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
from transformers import pipeline
import warnings
import logging
warnings.simplefilter('ignore')
logging.disable(logging.WARNING)
model_path = "cardiffnlp/twitter-xlm-roberta-base-sentiment"
def predict(image):
cap = pipeline('image-to-text')
genereated_dict = cap(image)
final = str(genereated_dict)
def sentiment_analysis(phrase):
pipe = pipeline('text-classification')
sentiment = pipe(phrase)
return str(senti)
senti = sentiment_analysis(final)
output = final[20:-2]
return output
input = gr.inputs.Image(
label="Upload your Image and wait for 8-12 seconds!", type='pil', optional=False)
output = gr.outputs.Textbox(label="Captions")
title = "Content ModX UI "
interface = gr.Interface(
fn=predict,
inputs=input,
theme="grass",
outputs= output,
title=title,
)
interface.launch()
|