Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,12 +20,12 @@ def detect_objects(images):
|
|
| 20 |
all_bboxes2.append(boxes2)
|
| 21 |
return all_bboxes, all_bboxes2
|
| 22 |
|
| 23 |
-
def create_solutions(image_urls, all_bboxes, all_bboxes2):
|
| 24 |
solutions = []
|
| 25 |
img_id = 1
|
| 26 |
box_id = 1
|
| 27 |
category_id = 1
|
| 28 |
-
for image_url, bboxes, bboxes2 in zip(image_urls, all_bboxes, all_bboxes2):
|
| 29 |
for box, box2 in zip(bboxes, bboxes2):
|
| 30 |
if isinstance(box2[0], list):
|
| 31 |
w = box2[0][2]
|
|
@@ -38,7 +38,7 @@ def create_solutions(image_urls, all_bboxes, all_bboxes2):
|
|
| 38 |
seg = [[]]
|
| 39 |
|
| 40 |
ans = {"segmentation": seg,"area": area,"iscrowd": 0,"image_id": img_id,"bbox": box,"category_id": category_id,"id": box_id}
|
| 41 |
-
obj = {"url": image_url, "answer": [ans], "qcUser" : None }
|
| 42 |
solutions.append(obj)
|
| 43 |
box_id += 1
|
| 44 |
img_id += 1
|
|
@@ -61,6 +61,7 @@ def process_images(params):
|
|
| 61 |
return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
|
| 62 |
|
| 63 |
image_urls = params.get("urls", [])
|
|
|
|
| 64 |
# api = params.get("api", "")
|
| 65 |
# job_id = params.get("job_id", "")
|
| 66 |
print(image_urls)
|
|
@@ -76,7 +77,7 @@ def process_images(params):
|
|
| 76 |
return {"error": f"Error loading images: {str(e)}"}
|
| 77 |
|
| 78 |
all_bboxes, all_bboxes2 = detect_objects(images) # Perform object detection
|
| 79 |
-
solutions = create_solutions(image_urls, all_bboxes, all_bboxes2) # Create solutions with image URLs and bounding boxes
|
| 80 |
|
| 81 |
# result_url = f"{api}/{job_id}"
|
| 82 |
# send_results_to_api(solutions, result_url)
|
|
|
|
| 20 |
all_bboxes2.append(boxes2)
|
| 21 |
return all_bboxes, all_bboxes2
|
| 22 |
|
| 23 |
+
def create_solutions(image_urls, all_bboxes, all_bboxes2, file_ids):
|
| 24 |
solutions = []
|
| 25 |
img_id = 1
|
| 26 |
box_id = 1
|
| 27 |
category_id = 1
|
| 28 |
+
for image_url, bboxes, bboxes2, file_id in zip(image_urls, all_bboxes, all_bboxes2, file_ids):
|
| 29 |
for box, box2 in zip(bboxes, bboxes2):
|
| 30 |
if isinstance(box2[0], list):
|
| 31 |
w = box2[0][2]
|
|
|
|
| 38 |
seg = [[]]
|
| 39 |
|
| 40 |
ans = {"segmentation": seg,"area": area,"iscrowd": 0,"image_id": img_id,"bbox": box,"category_id": category_id,"id": box_id}
|
| 41 |
+
obj = {"url": image_url, "answer": [ans], "qcUser" : None, "normalfileID": file_id}
|
| 42 |
solutions.append(obj)
|
| 43 |
box_id += 1
|
| 44 |
img_id += 1
|
|
|
|
| 61 |
return {"error": f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
|
| 62 |
|
| 63 |
image_urls = params.get("urls", [])
|
| 64 |
+
file_id = params.get("normalfileID",[])
|
| 65 |
# api = params.get("api", "")
|
| 66 |
# job_id = params.get("job_id", "")
|
| 67 |
print(image_urls)
|
|
|
|
| 77 |
return {"error": f"Error loading images: {str(e)}"}
|
| 78 |
|
| 79 |
all_bboxes, all_bboxes2 = detect_objects(images) # Perform object detection
|
| 80 |
+
solutions = create_solutions(image_urls, all_bboxes, all_bboxes2, file_id) # Create solutions with image URLs and bounding boxes
|
| 81 |
|
| 82 |
# result_url = f"{api}/{job_id}"
|
| 83 |
# send_results_to_api(solutions, result_url)
|