Spaces:
Runtime error
Runtime error
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() | |