import numpy as np import os import gradio as gr import torch from PIL import Image os.environ["WANDB_DISABLED"] = "true" from datasets import load_dataset, load_metric from transformers import ( AutoConfig, AutoModelForSequenceClassification, AutoTokenizer, TrainingArguments, logging, pipeline ) id2label = {0: "negative", 1: "neutral", 2: "positive"} label2id = {"negative": 0, "neutral": 1, "positive": 2} model = AutoModelForSequenceClassification.from_pretrained( model="FFZG-cleopatra/M2SA", num_labels=3, id2label=id2label, label2id=label2id ) def predict_sentiment(text, image): print(text, image) prediction = None with torch.no_grad(): model(x) print(analyzer(x)) return prediction interface = gr.Interface( fn=lambda text, image: predict_sentiment(text, image), inputs=[gr.inputs.Textbox(),gr.inputs.Image(shape=(224, 224))], outputs=['text'], title='Multilingual-Multimodal-Sentiment-Analysis', examples= ["I love tea","I hate coffee"], description='Get the positive/neutral/negative sentiment for the given input.' ) interface.launch(inline = False)