Spaces:
Sleeping
Sleeping
Update api_server.py
Browse files- api_server.py +3 -6
api_server.py
CHANGED
@@ -165,8 +165,6 @@ def predict():
|
|
165 |
print(f"警告:{element} 沒有找到相關的 JPG 檔案")
|
166 |
continue
|
167 |
|
168 |
-
element_list.append(element)
|
169 |
-
|
170 |
for yolo_img in yolo_file: # 每張切圖yolo_img
|
171 |
print("***** 4. START CLIP *****")
|
172 |
client = Client(GRADIO_URL)
|
@@ -177,6 +175,7 @@ def predict():
|
|
177 |
)
|
178 |
top_k_words.append(clip_result) # CLIP預測3個結果(top_k_words)
|
179 |
encoded_images.append(image_to_base64(yolo_img))
|
|
|
180 |
print(f"===== CLIP result:{top_k_words} =====\n")
|
181 |
|
182 |
# if element_counts[element] > 1: #某隻角色的數量>1
|
@@ -196,15 +195,13 @@ def predict():
|
|
196 |
'objects': [
|
197 |
{
|
198 |
'element': element,
|
199 |
-
'images':
|
200 |
{
|
201 |
'encoded_image': encoded_image,
|
202 |
'description_list': description_list
|
203 |
}
|
204 |
-
for encoded_image, description_list in zip(encoded_images, top_k_words)
|
205 |
-
]
|
206 |
}
|
207 |
-
for element,
|
208 |
]
|
209 |
}
|
210 |
|
|
|
165 |
print(f"警告:{element} 沒有找到相關的 JPG 檔案")
|
166 |
continue
|
167 |
|
|
|
|
|
168 |
for yolo_img in yolo_file: # 每張切圖yolo_img
|
169 |
print("***** 4. START CLIP *****")
|
170 |
client = Client(GRADIO_URL)
|
|
|
175 |
)
|
176 |
top_k_words.append(clip_result) # CLIP預測3個結果(top_k_words)
|
177 |
encoded_images.append(image_to_base64(yolo_img))
|
178 |
+
element_list.append(element)
|
179 |
print(f"===== CLIP result:{top_k_words} =====\n")
|
180 |
|
181 |
# if element_counts[element] > 1: #某隻角色的數量>1
|
|
|
195 |
'objects': [
|
196 |
{
|
197 |
'element': element,
|
198 |
+
'images':
|
199 |
{
|
200 |
'encoded_image': encoded_image,
|
201 |
'description_list': description_list
|
202 |
}
|
|
|
|
|
203 |
}
|
204 |
+
for element, encoded_image, description_list in zip(element_list, encoded_images, top_k_words)
|
205 |
]
|
206 |
}
|
207 |
|