Spaces:
Sleeping
Sleeping
Om Tiwari
commited on
Commit
Β·
3618817
1
Parent(s):
1cb4f23
initial commit
Browse files- README.md +2 -2
- app.py +32 -0
- memeclf.h5 +3 -0
- requirements.txt +96 -0
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
title: MemeDetect
|
3 |
emoji: π
|
4 |
-
colorFrom:
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.16.0
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: MemeDetect
|
3 |
emoji: π
|
4 |
+
colorFrom: red
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.16.0
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from tensorflow import keras
|
4 |
+
from tensorflow.keras.preprocessing.image import img_to_array
|
5 |
+
from tensorflow.image import resize
|
6 |
+
|
7 |
+
model = keras.models.load_model('memeclf.h5')
|
8 |
+
|
9 |
+
|
10 |
+
def predict(image):
|
11 |
+
img = resize(image, (256, 256))
|
12 |
+
img = img_to_array(img)
|
13 |
+
img = tf.expand_dims(img, axis=0)
|
14 |
+
img = tf.cast(img/255. ,tf.float32)
|
15 |
+
|
16 |
+
predictions = model.predict(img)
|
17 |
+
if predictions[0] < 0.5:
|
18 |
+
return "Image is a meme"
|
19 |
+
else:
|
20 |
+
return "Image is not a meme"
|
21 |
+
|
22 |
+
|
23 |
+
interface = gr.Interface(
|
24 |
+
fn=predict,
|
25 |
+
inputs=gr.Image(),
|
26 |
+
outputs="label",
|
27 |
+
title="Meme Classifier",
|
28 |
+
description="Upload an image and the model will predict if it's a meme or not.",
|
29 |
+
theme="huggingface"
|
30 |
+
)
|
31 |
+
interface.launch()
|
32 |
+
|
memeclf.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:921c57daa510a4d8ce701b5fb0faab72f822ac7a0ca7a699de34813605e820ac
|
3 |
+
size 178225088
|
requirements.txt
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==2.1.0
|
2 |
+
aiofiles==23.2.1
|
3 |
+
altair==5.2.0
|
4 |
+
annotated-types==0.6.0
|
5 |
+
anyio==4.2.0
|
6 |
+
astunparse==1.6.3
|
7 |
+
attrs==23.2.0
|
8 |
+
cachetools==5.3.2
|
9 |
+
certifi==2023.11.17
|
10 |
+
charset-normalizer==3.3.2
|
11 |
+
click==8.1.7
|
12 |
+
colorama==0.4.6
|
13 |
+
contourpy==1.2.0
|
14 |
+
cycler==0.12.1
|
15 |
+
fastapi==0.109.0
|
16 |
+
ffmpy==0.3.1
|
17 |
+
filelock==3.13.1
|
18 |
+
flatbuffers==23.5.26
|
19 |
+
fonttools==4.47.2
|
20 |
+
fsspec==2023.12.2
|
21 |
+
gast==0.5.4
|
22 |
+
google-auth==2.27.0
|
23 |
+
google-auth-oauthlib==1.2.0
|
24 |
+
google-pasta==0.2.0
|
25 |
+
gradio==4.16.0
|
26 |
+
gradio_client==0.8.1
|
27 |
+
grpcio==1.60.0
|
28 |
+
h11==0.14.0
|
29 |
+
h5py==3.10.0
|
30 |
+
httpcore==1.0.2
|
31 |
+
httpx==0.26.0
|
32 |
+
huggingface-hub==0.20.3
|
33 |
+
idna==3.6
|
34 |
+
importlib-resources==6.1.1
|
35 |
+
Jinja2==3.1.3
|
36 |
+
jsonschema==4.21.1
|
37 |
+
jsonschema-specifications==2023.12.1
|
38 |
+
keras==2.15.0
|
39 |
+
kiwisolver==1.4.5
|
40 |
+
libclang==16.0.6
|
41 |
+
Markdown==3.5.2
|
42 |
+
markdown-it-py==3.0.0
|
43 |
+
MarkupSafe==2.1.4
|
44 |
+
matplotlib==3.8.2
|
45 |
+
mdurl==0.1.2
|
46 |
+
ml-dtypes==0.2.0
|
47 |
+
numpy==1.26.3
|
48 |
+
oauthlib==3.2.2
|
49 |
+
opt-einsum==3.3.0
|
50 |
+
orjson==3.9.12
|
51 |
+
packaging==23.2
|
52 |
+
pandas==2.2.0
|
53 |
+
pickles==0.1.1
|
54 |
+
pillow==10.2.0
|
55 |
+
protobuf==4.23.4
|
56 |
+
pyasn1==0.5.1
|
57 |
+
pyasn1-modules==0.3.0
|
58 |
+
pydantic==2.6.0
|
59 |
+
pydantic_core==2.16.1
|
60 |
+
pydub==0.25.1
|
61 |
+
Pygments==2.17.2
|
62 |
+
pyparsing==3.1.1
|
63 |
+
python-dateutil==2.8.2
|
64 |
+
python-multipart==0.0.6
|
65 |
+
pytz==2023.4
|
66 |
+
PyYAML==6.0.1
|
67 |
+
referencing==0.33.0
|
68 |
+
requests==2.31.0
|
69 |
+
requests-oauthlib==1.3.1
|
70 |
+
rich==13.7.0
|
71 |
+
rpds-py==0.17.1
|
72 |
+
rsa==4.9
|
73 |
+
ruff==0.1.15
|
74 |
+
semantic-version==2.10.0
|
75 |
+
shellingham==1.5.4
|
76 |
+
six==1.16.0
|
77 |
+
sniffio==1.3.0
|
78 |
+
starlette==0.35.1
|
79 |
+
tensorboard==2.15.1
|
80 |
+
tensorboard-data-server==0.7.2
|
81 |
+
tensorflow==2.15.0
|
82 |
+
tensorflow-estimator==2.15.0
|
83 |
+
tensorflow-intel==2.15.0
|
84 |
+
tensorflow-io-gcs-filesystem==0.31.0
|
85 |
+
termcolor==2.4.0
|
86 |
+
tomlkit==0.12.0
|
87 |
+
toolz==0.12.1
|
88 |
+
tqdm==4.66.1
|
89 |
+
typer==0.9.0
|
90 |
+
typing_extensions==4.9.0
|
91 |
+
tzdata==2023.4
|
92 |
+
urllib3==2.2.0
|
93 |
+
uvicorn==0.27.0.post1
|
94 |
+
websockets==11.0.3
|
95 |
+
Werkzeug==3.0.1
|
96 |
+
wrapt==1.14.1
|