drhead commited on
Commit
e661577
1 Parent(s): 0cdffb9
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -139,14 +139,12 @@ def create_tags(image, threshold):
139
  indices = torch.where(probabilities > threshold)[0]
140
  values = probabilities[indices]
141
 
142
- temp = []
143
  tag_score = dict()
144
  for i in range(indices.size(0)):
145
- temp.append([allowed_tags[indices[i]], values[i].item()])
146
  tag_score[allowed_tags[indices[i]]] = values[i].item()
147
- temp = [t[0] for t in temp]
148
- text_no_impl = ", ".join(temp)
149
- return text_no_impl, tag_score
150
 
151
  with gr.Blocks() as demo:
152
  gr.Markdown("""
 
139
  indices = torch.where(probabilities > threshold)[0]
140
  values = probabilities[indices]
141
 
 
142
  tag_score = dict()
143
  for i in range(indices.size(0)):
 
144
  tag_score[allowed_tags[indices[i]]] = values[i].item()
145
+ sorted_tag_score = dict(sorted(tag_score.items(), key=lambda item: item[1], reverse=True))
146
+ text_no_impl = ", ".join(sorted_tag_score.keys())
147
+ return text_no_impl, sorted_tag_score
148
 
149
  with gr.Blocks() as demo:
150
  gr.Markdown("""