janasumit2911 commited on
Commit
4702a95
·
verified ·
1 Parent(s): 8e2db4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -41,6 +41,15 @@ def create_solutions(image_urls, all_bboxes, all_bboxes2):
41
  img_id += 1
42
  return solutions
43
 
 
 
 
 
 
 
 
 
 
44
  def process_images(params):
45
  # Parse the JSON string into a dictionary
46
  params = json.loads(params)
@@ -55,7 +64,7 @@ def process_images(params):
55
  solutions = create_solutions(image_urls, all_bboxes, all_bboxes2) # Create solutions with image URLs and bounding boxes
56
 
57
  result_url = f"{api}/{job_id}"
58
- # send_results_to_api(solutions, result_url)
59
 
60
  return json.dumps({"solutions": solutions}, indent=4)
61
 
 
41
  img_id += 1
42
  return solutions
43
 
44
+ def send_results_to_api(data, result_url):
45
+ # Example function to send results to an API
46
+ headers = {"Content-Type": "application/json"}
47
+ response = requests.post(result_url, json=data, headers=headers)
48
+ if response.status_code == 200:
49
+ return response.json() # Return any response from the API if needed
50
+ else:
51
+ return {"error": f"Failed to send results to API: {response.status_code}"}
52
+
53
  def process_images(params):
54
  # Parse the JSON string into a dictionary
55
  params = json.loads(params)
 
64
  solutions = create_solutions(image_urls, all_bboxes, all_bboxes2) # Create solutions with image URLs and bounding boxes
65
 
66
  result_url = f"{api}/{job_id}"
67
+ send_results_to_api(solutions, result_url)
68
 
69
  return json.dumps({"solutions": solutions}, indent=4)
70