Spaces:
Build error
Build error
Vincent Claes
commited on
Commit
·
44602c4
1
Parent(s):
d70f01c
use threshold
Browse files
app.py
CHANGED
@@ -10,7 +10,8 @@ from transformers import CLIPProcessor, CLIPModel
|
|
10 |
|
11 |
checkpoint = "vincentclaes/emoji-predictor"
|
12 |
adjectives = pd.read_table("./adjectives.txt", header=None)[0].to_list()
|
13 |
-
K =
|
|
|
14 |
APP_NAME = "emoji-tagging"
|
15 |
BUCKET = "drift-pilot-ml-model"
|
16 |
|
@@ -42,7 +43,7 @@ def get_tag(emoji, tags="", expected="", model=model, processor=processor, K=K):
|
|
42 |
probs_formatted = torch.tensor([prob[0] for prob in probs])
|
43 |
values, indices = probs_formatted.topk(K)
|
44 |
return "Tag (confidence): " + ", ".join(
|
45 |
-
[f"{tags[i]} ({round(v.item(), 2)})" for v, i in zip(values, indices)]
|
46 |
)
|
47 |
|
48 |
|
@@ -50,10 +51,12 @@ title = "Tagging an Emoji"
|
|
50 |
description = """You provide an Emoji and our few-shot fine tuned CLIP model will suggest some tags that are appropriate.\n
|
51 |
|
52 |
- We use the [228 most common adjectives in english](https://grammar.yourdictionary.com/parts-of-speech/adjectives/list-of-adjective-words.html).\n
|
53 |
-
- You can also specify your own custom tags.
|
54 |
|
55 |
love,hate,fun,bitterness,passion,dying,bliss
|
56 |
|
|
|
|
|
57 |
"""
|
58 |
|
59 |
examples = [[f"emojis/{i}.png"] for i in range(32)]
|
|
|
10 |
|
11 |
checkpoint = "vincentclaes/emoji-predictor"
|
12 |
adjectives = pd.read_table("./adjectives.txt", header=None)[0].to_list()
|
13 |
+
K = 10
|
14 |
+
THRESHOLD = 0.05
|
15 |
APP_NAME = "emoji-tagging"
|
16 |
BUCKET = "drift-pilot-ml-model"
|
17 |
|
|
|
43 |
probs_formatted = torch.tensor([prob[0] for prob in probs])
|
44 |
values, indices = probs_formatted.topk(K)
|
45 |
return "Tag (confidence): " + ", ".join(
|
46 |
+
[f"{tags[i]} ({round(v.item(), 2)})" for v, i in zip(values, indices) if v >= THRESHOLD]
|
47 |
)
|
48 |
|
49 |
|
|
|
51 |
description = """You provide an Emoji and our few-shot fine tuned CLIP model will suggest some tags that are appropriate.\n
|
52 |
|
53 |
- We use the [228 most common adjectives in english](https://grammar.yourdictionary.com/parts-of-speech/adjectives/list-of-adjective-words.html).\n
|
54 |
+
- You can also specify your own custom tags. Try with;
|
55 |
|
56 |
love,hate,fun,bitterness,passion,dying,bliss
|
57 |
|
58 |
+
- We show max 10 tags and only when the confidence is higher than 5% (0.05)
|
59 |
+
|
60 |
"""
|
61 |
|
62 |
examples = [[f"emojis/{i}.png"] for i in range(32)]
|