Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,26 @@ base_model:
|
|
5 |
pipeline_tag: image-classification
|
6 |
tags:
|
7 |
- image-classification
|
8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
pipeline_tag: image-classification
|
6 |
tags:
|
7 |
- image-classification
|
8 |
+
---
|
9 |
+
|
10 |
+
```py
|
11 |
+
import gradio as gr
|
12 |
+
from transformers import pipeline
|
13 |
+
|
14 |
+
classifier = pipeline("image-classification", model="TPM-28/MemeDetector")
|
15 |
+
|
16 |
+
def classify_image(image):
|
17 |
+
predictions = classifier(image)
|
18 |
+
result = {pred['label']: pred['score'] for pred in predictions}
|
19 |
+
return result
|
20 |
+
|
21 |
+
interface = gr.Interface(
|
22 |
+
fn=classify_image,
|
23 |
+
inputs=gr.Image(type="pil"),
|
24 |
+
outputs=gr.Label(num_top_classes=3),
|
25 |
+
title="Meme Detector"
|
26 |
+
)
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
interface.launch()
|
30 |
+
```
|