File size: 1,188 Bytes
70b16bd
 
 
0833e94
 
70b16bd
 
 
 
 
 
0833e94
70b16bd
 
 
 
 
 
0833e94
 
 
 
 
 
 
 
70b16bd
 
0833e94
 
 
 
 
 
 
 
70b16bd
 
 
6e8de0e
0833e94
70b16bd
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
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)