Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,31 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
from io import BytesIO
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
+
api_key = os.environ['API_KEY']
|
| 8 |
+
|
| 9 |
+
API_URL = "https://api-inference.huggingface.co/models/Hrishikesh332/autotrain-meme-classification-42897109437"
|
| 10 |
+
headers = {"Authorization": f"Bearer {api_key}"}
|
| 11 |
+
|
| 12 |
+
def query(data : bytes):
|
| 13 |
+
|
| 14 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
| 15 |
+
return response.json()
|
| 16 |
+
|
| 17 |
+
st.markdown("<h1 style='text-align: center;'>Memeter 💬</h1>", unsafe_allow_html=True)
|
| 18 |
+
st.markdown("---")
|
| 19 |
+
with st.sidebar:
|
| 20 |
+
st.title("Memometer")
|
| 21 |
+
st.caption('''
|
| 22 |
+
Memeter is an application used for the classification of whether the images provided is meme or not meme
|
| 23 |
+
''', unsafe_allow_html=False)
|
| 24 |
+
|
| 25 |
+
img = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])
|
| 26 |
+
|
| 27 |
+
if img is not None:
|
| 28 |
+
|
| 29 |
+
data = img.read()
|
| 30 |
+
output = query(data)
|
| 31 |
+
st.write("Predicted Output:", output)
|