Ajaymaurya1008 commited on
Commit
ef9a2a1
·
1 Parent(s): 3bdc2cd

Update app.py

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