Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -65,7 +65,7 @@ Both of these features are extracted from the tag wiki pages, but some valid e62
|
|
| 65 |
|
| 66 |
Yes. We normalized the favorite counts of each image to a range of 0-9, with 0 being the lowest favcount, and 9 being the highest.
|
| 67 |
You can include any of these special tags: "score:0", "score:1", "score:2", "score:3", "score:4", "score:5", "score:6", "score:7", "score:8", "score:9"
|
| 68 |
-
in your list to bias the output toward artists with higher or lower scoring images.
|
| 69 |
|
| 70 |
## Are there any other special tricks?
|
| 71 |
|
|
@@ -134,7 +134,8 @@ def extract_tags(tree):
|
|
| 134 |
def _traverse(node):
|
| 135 |
if isinstance(node, Token) and node.type == '__ANON_1':
|
| 136 |
tag_position = node.start_pos
|
| 137 |
-
tag_text = node.value.strip()
|
|
|
|
| 138 |
tags_with_positions.append((tag_text, tag_position))
|
| 139 |
elif not isinstance(node, Token):
|
| 140 |
for child in node.children:
|
|
@@ -419,10 +420,8 @@ def find_similar_tags(test_tags, similarity_weight, allow_nsfw_tags):
|
|
| 419 |
start_pos = tag_info['start_pos']
|
| 420 |
end_pos = tag_info['end_pos']
|
| 421 |
|
|
|
|
| 422 |
|
| 423 |
-
print(original_tag, modified_tag, start_pos, end_pos)
|
| 424 |
-
|
| 425 |
-
|
| 426 |
if modified_tag in special_tags:
|
| 427 |
continue
|
| 428 |
|
|
@@ -464,7 +463,7 @@ def find_similar_tags(test_tags, similarity_weight, allow_nsfw_tags):
|
|
| 464 |
result = sorted(result, key=lambda x: x[1], reverse=True)[:10]
|
| 465 |
html_content += create_html_tables_for_tags(modified_tag, result, find_similar_tags.tag2count, find_similar_tags.tag2idwiki)
|
| 466 |
|
| 467 |
-
bad_entities.append({"entity":"
|
| 468 |
|
| 469 |
tags_added=True
|
| 470 |
# If no tags were processed, add a message
|
|
@@ -507,6 +506,7 @@ def find_similar_artists(original_tags_string, top_n, similarity_weight, allow_n
|
|
| 507 |
unseen_tags_data, bad_entities = find_similar_tags(tag_data, similarity_weight, allow_nsfw_tags)
|
| 508 |
|
| 509 |
bad_tags_illustrated_string = {"text":new_tags_string, "entities":bad_entities}
|
|
|
|
| 510 |
|
| 511 |
modified_tags = [tag_info['modified_tag'] for tag_info in tag_data]
|
| 512 |
X_new_image = vectorizer.transform([','.join(modified_tags + removed_tags)])
|
|
@@ -541,7 +541,7 @@ with gr.Blocks() as app:
|
|
| 541 |
num_artists = gr.Slider(minimum=1, maximum=100, value=10, step=1, label="Number of artists")
|
| 542 |
allow_nsfw = gr.Checkbox(label="Allow NSFW Tags", value=False)
|
| 543 |
with gr.Row():
|
| 544 |
-
bad_tags_illustrated_string = gr.HighlightedText()
|
| 545 |
with gr.Row():
|
| 546 |
with gr.Column(scale=1):
|
| 547 |
top_artists = gr.HTML(label="Top Artists", value=create_html_placeholder(title="Top Artists"))
|
|
|
|
| 65 |
|
| 66 |
Yes. We normalized the favorite counts of each image to a range of 0-9, with 0 being the lowest favcount, and 9 being the highest.
|
| 67 |
You can include any of these special tags: "score:0", "score:1", "score:2", "score:3", "score:4", "score:5", "score:6", "score:7", "score:8", "score:9"
|
| 68 |
+
in your list to bias the output toward artists with higher or lower scoring images.
|
| 69 |
|
| 70 |
## Are there any other special tricks?
|
| 71 |
|
|
|
|
| 134 |
def _traverse(node):
|
| 135 |
if isinstance(node, Token) and node.type == '__ANON_1':
|
| 136 |
tag_position = node.start_pos
|
| 137 |
+
#tag_text = node.value.strip()
|
| 138 |
+
tag_text = node.value
|
| 139 |
tags_with_positions.append((tag_text, tag_position))
|
| 140 |
elif not isinstance(node, Token):
|
| 141 |
for child in node.children:
|
|
|
|
| 420 |
start_pos = tag_info['start_pos']
|
| 421 |
end_pos = tag_info['end_pos']
|
| 422 |
|
| 423 |
+
#print(original_tag, modified_tag, start_pos, end_pos)
|
| 424 |
|
|
|
|
|
|
|
|
|
|
| 425 |
if modified_tag in special_tags:
|
| 426 |
continue
|
| 427 |
|
|
|
|
| 463 |
result = sorted(result, key=lambda x: x[1], reverse=True)[:10]
|
| 464 |
html_content += create_html_tables_for_tags(modified_tag, result, find_similar_tags.tag2count, find_similar_tags.tag2idwiki)
|
| 465 |
|
| 466 |
+
bad_entities.append({"entity":"*", "start":start_pos, "end":end_pos})
|
| 467 |
|
| 468 |
tags_added=True
|
| 469 |
# If no tags were processed, add a message
|
|
|
|
| 506 |
unseen_tags_data, bad_entities = find_similar_tags(tag_data, similarity_weight, allow_nsfw_tags)
|
| 507 |
|
| 508 |
bad_tags_illustrated_string = {"text":new_tags_string, "entities":bad_entities}
|
| 509 |
+
#bad_tags_illustrated_string = {"text":original_tags_string, "entities":bad_entities}
|
| 510 |
|
| 511 |
modified_tags = [tag_info['modified_tag'] for tag_info in tag_data]
|
| 512 |
X_new_image = vectorizer.transform([','.join(modified_tags + removed_tags)])
|
|
|
|
| 541 |
num_artists = gr.Slider(minimum=1, maximum=100, value=10, step=1, label="Number of artists")
|
| 542 |
allow_nsfw = gr.Checkbox(label="Allow NSFW Tags", value=False)
|
| 543 |
with gr.Row():
|
| 544 |
+
bad_tags_illustrated_string = gr.HighlightedText(label="Visual depiction of bad tags. Character offsets may be buggy.")
|
| 545 |
with gr.Row():
|
| 546 |
with gr.Column(scale=1):
|
| 547 |
top_artists = gr.HTML(label="Top Artists", value=create_html_placeholder(title="Top Artists"))
|