Spaces:
Running
Running
FoodDesert
commited on
Upload app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ with h5py.File('complete_artist_data.hdf5', 'r') as f:
|
|
19 |
# Load artist names and decode to strings
|
20 |
artist_names = [name.decode() for name in f['artist_names'][:]]
|
21 |
|
22 |
-
def find_similar_artists(new_tags_string):
|
23 |
new_image_tags = [tag.strip() for tag in new_tags_string.split(",")]
|
24 |
unseen_tags = set(new_image_tags) - set(vectorizer.vocabulary_.keys())
|
25 |
unseen_tags_str = f'Unseen Tags: {", ".join(unseen_tags)}' if unseen_tags else 'No unseen tags.'
|
@@ -27,7 +27,6 @@ def find_similar_artists(new_tags_string):
|
|
27 |
X_new_image = vectorizer.transform([','.join(new_image_tags)])
|
28 |
similarities = cosine_similarity(X_new_image, X_artist)[0]
|
29 |
|
30 |
-
top_n = 20
|
31 |
top_artist_indices = np.argsort(similarities)[-top_n:][::-1]
|
32 |
bottom_artist_indices = np.argsort(similarities)[:top_n]
|
33 |
|
@@ -42,10 +41,13 @@ def find_similar_artists(new_tags_string):
|
|
42 |
|
43 |
iface = gr.Interface(
|
44 |
fn=find_similar_artists,
|
45 |
-
inputs=
|
|
|
|
|
|
|
46 |
outputs="text",
|
47 |
-
title="
|
48 |
-
description="Enter
|
49 |
)
|
50 |
|
51 |
iface.launch()
|
|
|
19 |
# Load artist names and decode to strings
|
20 |
artist_names = [name.decode() for name in f['artist_names'][:]]
|
21 |
|
22 |
+
def find_similar_artists(new_tags_string, top_n):
|
23 |
new_image_tags = [tag.strip() for tag in new_tags_string.split(",")]
|
24 |
unseen_tags = set(new_image_tags) - set(vectorizer.vocabulary_.keys())
|
25 |
unseen_tags_str = f'Unseen Tags: {", ".join(unseen_tags)}' if unseen_tags else 'No unseen tags.'
|
|
|
27 |
X_new_image = vectorizer.transform([','.join(new_image_tags)])
|
28 |
similarities = cosine_similarity(X_new_image, X_artist)[0]
|
29 |
|
|
|
30 |
top_artist_indices = np.argsort(similarities)[-top_n:][::-1]
|
31 |
bottom_artist_indices = np.argsort(similarities)[:top_n]
|
32 |
|
|
|
41 |
|
42 |
iface = gr.Interface(
|
43 |
fn=find_similar_artists,
|
44 |
+
inputs=[
|
45 |
+
gr.Textbox(label="Enter image tags", placeholder="fox, outside, detailed background"),
|
46 |
+
gr.Slider(minimum=1, maximum=100, default=10, step=1, label="Number of artists")
|
47 |
+
],
|
48 |
outputs="text",
|
49 |
+
title="Tagset Completer",
|
50 |
+
description="Enter a list of comma-separated e6 tags"
|
51 |
)
|
52 |
|
53 |
iface.launch()
|