File size: 1,239 Bytes
8f37fff
0cbbcf7
 
8f37fff
42a1798
827ca4c
8f37fff
 
 
 
 
0cbbcf7
 
 
8f37fff
 
 
 
 
 
 
 
0cbbcf7
 
 
 
 
 
 
 
 
8f37fff
0cbbcf7
 
 
 
 
 
42a1798
 
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 streamlit as st
import requests
from io import BytesIO
from PIL import Image
from transformers import AutoFeatureExtractor, AutoModelForImageClassification

def load_image(img):
    im=Image.open(img)
    return im
size=20

extractor = AutoFeatureExtractor.from_pretrained("Hrishikesh332/autotrain-meme-classification-42897109437")
model = AutoModelForImageClassification.from_pretrained("Hrishikesh332/autotrain-meme-classification-42897109437")

st.markdown("<h1 style='text-align: center;'>Memeter 💬</h1>", unsafe_allow_html=True)
st.markdown("---")
with st.sidebar:
    st.title("Memometer")
    st.caption('''
    Memeter is an application used for the classification of whether the images provided is meme or not meme
    ''', unsafe_allow_html=False)

img = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])

def predict(image):
    inputs = extractor(images=image, return_tensors="pt")

    outputs = model(**inputs)
    scores = outputs.logits.detach().numpy()
    return scores
    
if img is not None:
    try:
        image = Image.open(BytesIO(img.read()))
        s = predict(image)
        st.write("Value:", s)
    except:
        st.write("Pleas do upload the image in the correct format!")