D3V1L1810 commited on
Commit
dabedde
·
verified ·
1 Parent(s): d6fbe5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -25,7 +25,7 @@ def create_solutions(image_urls, all_bboxes, all_bboxes2):
25
  img_id =1
26
  box_id =1
27
  cat_id =1
28
- for image_url, bbox, bbox2 in zip(image_urls, all_bboxes, all_bboxes2): # Loop through each image ID and its corresponding prediction
29
 
30
  for subbox, subbox2 in zip(bbox, bbox2):
31
 
@@ -36,9 +36,11 @@ def create_solutions(image_urls, all_bboxes, all_bboxes2):
36
  ans = {"segmentation":seg, "area":area, 'iscrowd':0, "image_id":img_id, "bbox": subbox, "category_id":cat_id, "id":box_id }
37
  ansx=[]
38
  ansx.append(ans)
39
- obj = {"url": image_url, 'answer':ansx}
40
  box_id +=1
41
- solutions.append(obj)
 
 
42
  img_id +=1
43
  return solutions
44
 
@@ -59,6 +61,7 @@ def process_images(params):
59
  return {"error":f"Invalid JSON input: {e.msg} at line {e.lineno} column {e.colno}"}
60
 
61
  image_urls = params.get("urls", [])
 
62
  # api = params.get("api", "")
63
  # job_id = params.get("job_id", "")
64
 
@@ -72,7 +75,7 @@ def process_images(params):
72
  return {"error": f"Error loading images: {str(e)}"}
73
 
74
  all_bboxes, all_bboxes2 = detect_objects(images) # Perform object detection
75
- solutions = create_solutions(image_urls, all_bboxes, all_bboxes2) # Create solutions with image URLs and bounding boxes
76
 
77
  # result_url = f"{api}/{job_id}"
78
  # send_results_to_api(solutions, result_url)
 
25
  img_id =1
26
  box_id =1
27
  cat_id =1
28
+ for image_url, bbox, bbox2, file_id in zip(image_urls, all_bboxes, all_bboxes2, file_ids): # Loop through each image ID and its corresponding prediction
29
 
30
  for subbox, subbox2 in zip(bbox, bbox2):
31
 
 
36
  ans = {"segmentation":seg, "area":area, 'iscrowd':0, "image_id":img_id, "bbox": subbox, "category_id":cat_id, "id":box_id }
37
  ansx=[]
38
  ansx.append(ans)
39
+
40
  box_id +=1
41
+ }
42
+
43
+ solutions.append({"url": image_url,'answer':ansx, "qcUser" : None, "normalfileID": file_id })
44
  img_id +=1
45
  return solutions
46
 
 
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_ids = params.get("normalfileID", [])
65
  # api = params.get("api", "")
66
  # job_id = params.get("job_id", "")
67
 
 
75
  return {"error": f"Error loading images: {str(e)}"}
76
 
77
  all_bboxes, all_bboxes2 = detect_objects(images) # Perform object detection
78
+ solutions = create_solutions(image_urls, all_bboxes, all_bboxes2, file_ids) # Create solutions with image URLs and bounding boxes
79
 
80
  # result_url = f"{api}/{job_id}"
81
  # send_results_to_api(solutions, result_url)