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