Update README.md and app.py for enhanced UI experience
Browse files
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: MetaCLIP
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.50.2
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
title: MetaCLIP
|
3 |
+
emoji: 👁️
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: orange
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.50.2
|
8 |
app_file: app.py
|
app.py
CHANGED
@@ -5,6 +5,16 @@ import numpy as np
|
|
5 |
from transformers import CLIPProcessor, CLIPModel
|
6 |
|
7 |
IMAGENET_CLASSES_FILE = "imagenet-classes.txt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
def load_text_lines(file_path: str) -> List[str]:
|
@@ -31,12 +41,21 @@ def classify_image(input_image) -> str:
|
|
31 |
|
32 |
|
33 |
with gr.Blocks() as demo:
|
34 |
-
gr.Markdown(
|
35 |
with gr.Row():
|
36 |
image = gr.Image(image_mode='RGB', type='pil')
|
37 |
-
output_text = gr.Textbox()
|
38 |
-
|
39 |
|
40 |
submit_button.click(classify_image, inputs=[image], outputs=output_text)
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
demo.queue(max_size=64).launch(debug=False)
|
|
|
5 |
from transformers import CLIPProcessor, CLIPModel
|
6 |
|
7 |
IMAGENET_CLASSES_FILE = "imagenet-classes.txt"
|
8 |
+
EXAMPLES = ["dog.jpeg", "car.png"]
|
9 |
+
|
10 |
+
MARKDOWN = """
|
11 |
+
# Zero-Shot Image Classification with MetaCLIP
|
12 |
+
|
13 |
+
This is the demo for a zero-shot image classification model based on
|
14 |
+
[MetaCLIP](https://github.com/facebookresearch/MetaCLIP), described in the paper
|
15 |
+
[Demystifying CLIP Data](https://arxiv.org/abs/2309.16671) that formalizes CLIP data
|
16 |
+
curation as a simple algorithm.
|
17 |
+
"""
|
18 |
|
19 |
|
20 |
def load_text_lines(file_path: str) -> List[str]:
|
|
|
41 |
|
42 |
|
43 |
with gr.Blocks() as demo:
|
44 |
+
gr.Markdown(MARKDOWN)
|
45 |
with gr.Row():
|
46 |
image = gr.Image(image_mode='RGB', type='pil')
|
47 |
+
output_text = gr.Textbox(label="Output")
|
48 |
+
submit_button = gr.Button("Submit")
|
49 |
|
50 |
submit_button.click(classify_image, inputs=[image], outputs=output_text)
|
51 |
|
52 |
+
gr.Examples(
|
53 |
+
examples=EXAMPLES,
|
54 |
+
fn=classify_image,
|
55 |
+
inputs=[image],
|
56 |
+
outputs=[output_text],
|
57 |
+
cache_examples=True,
|
58 |
+
run_on_click=True
|
59 |
+
)
|
60 |
+
|
61 |
demo.queue(max_size=64).launch(debug=False)
|
car.png
ADDED
dog.jpeg
ADDED