Not-Adam commited on
Commit
b5ae5fa
1 Parent(s): f72bcf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -12,7 +12,7 @@ from io import BytesIO
12
  import face_recognition
13
  from turtle import title
14
  from openai import OpenAI
15
- from collections import Counter, defaultdict
16
  from typing import List, Optional, Set, Dict, Any
17
  from transformers import pipeline
18
 
@@ -153,7 +153,7 @@ def shot(input, category, level):
153
  @spaces.GPU
154
  def get_colour(image_urls, category):
155
  colour_labels = [f"{colour}, clothing: {category}" for colour in COLOURS_DICT.keys()]
156
- responses = pipe(image_urls, candidate_labels=colour_labels, device=device)
157
 
158
  main_colour, main_score = get_most_common_label(responses)
159
  if main_colour not in COLOURS_DICT:
@@ -166,7 +166,7 @@ def get_colour(image_urls, category):
166
  labels = [label for key, values in COLOURS_DICT.items() if key != main_colour for label in values]
167
 
168
  labels = [f"{label}, clothing: {category}" for label in labels]
169
- responses = pipe(image_urls, candidate_labels=labels, device=device)
170
 
171
  most_common, sub_score = get_most_common_label(responses)
172
  sub_colours = [most_common]
@@ -176,7 +176,7 @@ def get_colour(image_urls, category):
176
  sub_key = next(key for key, values in COLOURS_DICT.items() if most_common in values)
177
  labels = [label for key, values in COLOURS_DICT.items() if key not in {main_colour, sub_key} for label in values]
178
  labels = [f"{label}, clothing: {category}" for label in labels]
179
- responses = pipe(image_urls, candidate_labels=labels, device=device)
180
 
181
  most_common, tertiary_score = get_most_common_label(responses)
182
  sub_colours.append(most_common)
 
12
  import face_recognition
13
  from turtle import title
14
  from openai import OpenAI
15
+ from collections import defaultdict
16
  from typing import List, Optional, Set, Dict, Any
17
  from transformers import pipeline
18
 
 
153
  @spaces.GPU
154
  def get_colour(image_urls, category):
155
  colour_labels = [f"{colour}, clothing: {category}" for colour in COLOURS_DICT.keys()]
156
+ responses = pipe(image_urls, candidate_labels=colour_labels)
157
 
158
  main_colour, main_score = get_most_common_label(responses)
159
  if main_colour not in COLOURS_DICT:
 
166
  labels = [label for key, values in COLOURS_DICT.items() if key != main_colour for label in values]
167
 
168
  labels = [f"{label}, clothing: {category}" for label in labels]
169
+ responses = pipe(image_urls, candidate_labels=labels)
170
 
171
  most_common, sub_score = get_most_common_label(responses)
172
  sub_colours = [most_common]
 
176
  sub_key = next(key for key, values in COLOURS_DICT.items() if most_common in values)
177
  labels = [label for key, values in COLOURS_DICT.items() if key not in {main_colour, sub_key} for label in values]
178
  labels = [f"{label}, clothing: {category}" for label in labels]
179
+ responses = pipe(image_urls, candidate_labels=labels)
180
 
181
  most_common, tertiary_score = get_most_common_label(responses)
182
  sub_colours.append(most_common)