user-agent
commited on
Commit
•
276e058
1
Parent(s):
3a0fa78
Update app.py
Browse files
app.py
CHANGED
@@ -77,31 +77,57 @@ def shot(input, category, level):
|
|
77 |
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
@spaces.GPU
|
81 |
def get_colour(image_urls, category):
|
82 |
colourLabels = list(COLOURS_DICT.keys())
|
83 |
for i in range(len(colourLabels)):
|
84 |
colourLabels[i] = colourLabels[i] + " clothing: " + category
|
85 |
|
|
|
|
|
|
|
86 |
responses = pipe(image_urls, candidate_labels=colourLabels)
|
87 |
-
# Get the most common colour
|
88 |
mainColour = responses[0][0]['label'].split(" clothing:")[0]
|
89 |
|
90 |
-
|
91 |
if mainColour not in COLOURS_DICT:
|
92 |
return None, None, None
|
93 |
|
94 |
-
# Add category to the end of each label
|
95 |
labels = COLOURS_DICT[mainColour]
|
96 |
for i in range(len(labels)):
|
97 |
labels[i] = labels[i] + " clothing: " + category
|
98 |
|
99 |
-
#
|
100 |
responses = pipe(image_urls, candidate_labels=labels)
|
101 |
subColour = responses[0][0]['label'].split(" clothing:")[0]
|
102 |
|
103 |
return subColour, mainColour, responses[0][0]['score']
|
104 |
|
|
|
|
|
105 |
@spaces.GPU
|
106 |
def get_predicted_attributes(image_urls, category):
|
107 |
# Assuming ATTRIBUTES_DICT and pipe are defined outside this function
|
|
|
77 |
|
78 |
|
79 |
|
80 |
+
# @spaces.GPU
|
81 |
+
# def get_colour(image_urls, category):
|
82 |
+
# colourLabels = list(COLOURS_DICT.keys())
|
83 |
+
# for i in range(len(colourLabels)):
|
84 |
+
# colourLabels[i] = colourLabels[i] + " clothing: " + category
|
85 |
+
|
86 |
+
# responses = pipe(image_urls, candidate_labels=colourLabels)
|
87 |
+
# # Get the most common colour
|
88 |
+
# mainColour = responses[0][0]['label'].split(" clothing:")[0]
|
89 |
+
|
90 |
+
|
91 |
+
# if mainColour not in COLOURS_DICT:
|
92 |
+
# return None, None, None
|
93 |
+
|
94 |
+
# # Add category to the end of each label
|
95 |
+
# labels = COLOURS_DICT[mainColour]
|
96 |
+
# for i in range(len(labels)):
|
97 |
+
# labels[i] = labels[i] + " clothing: " + category
|
98 |
+
|
99 |
+
# # Run pipeline in one go
|
100 |
+
# responses = pipe(image_urls, candidate_labels=labels)
|
101 |
+
# subColour = responses[0][0]['label'].split(" clothing:")[0]
|
102 |
+
|
103 |
+
# return subColour, mainColour, responses[0][0]['score']
|
104 |
@spaces.GPU
|
105 |
def get_colour(image_urls, category):
|
106 |
colourLabels = list(COLOURS_DICT.keys())
|
107 |
for i in range(len(colourLabels)):
|
108 |
colourLabels[i] = colourLabels[i] + " clothing: " + category
|
109 |
|
110 |
+
print("Colour Labels:", colourLabels) # Debug: Print colour labels
|
111 |
+
print("Image URLs:", image_urls) # Debug: Print image URLs
|
112 |
+
|
113 |
responses = pipe(image_urls, candidate_labels=colourLabels)
|
|
|
114 |
mainColour = responses[0][0]['label'].split(" clothing:")[0]
|
115 |
|
|
|
116 |
if mainColour not in COLOURS_DICT:
|
117 |
return None, None, None
|
118 |
|
|
|
119 |
labels = COLOURS_DICT[mainColour]
|
120 |
for i in range(len(labels)):
|
121 |
labels[i] = labels[i] + " clothing: " + category
|
122 |
|
123 |
+
print("Labels for pipe:", labels) # Debug: Confirm labels are correct
|
124 |
responses = pipe(image_urls, candidate_labels=labels)
|
125 |
subColour = responses[0][0]['label'].split(" clothing:")[0]
|
126 |
|
127 |
return subColour, mainColour, responses[0][0]['score']
|
128 |
|
129 |
+
|
130 |
+
|
131 |
@spaces.GPU
|
132 |
def get_predicted_attributes(image_urls, category):
|
133 |
# Assuming ATTRIBUTES_DICT and pipe are defined outside this function
|