Spaces:
Runtime error
Runtime error
Added proper details impl
#6
by
Not-Adam
- opened
app.py
CHANGED
@@ -166,13 +166,20 @@ def get_predicted_attributes(image_urls, category):
|
|
166 |
# Get the predicted values for the attribute
|
167 |
responses = pipe(image_urls, candidate_labels=values_formatted)
|
168 |
result = [response[0]['label'].split(", clothing:")[0] for response in responses]
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
# Clean up the results into one long string
|
178 |
for i, result in enumerate(common_result):
|
|
|
166 |
# Get the predicted values for the attribute
|
167 |
responses = pipe(image_urls, candidate_labels=values_formatted)
|
168 |
result = [response[0]['label'].split(", clothing:")[0] for response in responses]
|
169 |
+
common_result.append(Counter(result).most_common(1))
|
170 |
+
|
171 |
+
# If attribute is details, then remove the obtained label from the values, and get the next most common
|
172 |
+
if attribute == "details":
|
173 |
+
values_formatted.remove(result[0])
|
174 |
+
responses = pipe(image_urls, candidate_labels=values_formatted)
|
175 |
+
i = 0
|
176 |
+
while len(responses) > 0 and responses[0][0]['score'] > 0.8 and i < 2:
|
177 |
+
result = [response[0]['label'].split(", clothing:")[0] for response in responses]
|
178 |
+
common_result.append(Counter(result).most_common(1))
|
179 |
+
|
180 |
+
responses = pipe(image_urls, candidate_labels=values_formatted)
|
181 |
+
i += 1
|
182 |
+
|
183 |
|
184 |
# Clean up the results into one long string
|
185 |
for i, result in enumerate(common_result):
|