Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,6 +26,7 @@ def create_solutions(image_urls, names):
|
|
| 26 |
prediction_list.append(prediction)
|
| 27 |
obj = {"url": image_url, "answer": prediction_list, "qcUser" : None}
|
| 28 |
solutions.append(obj)
|
|
|
|
| 29 |
return solutions
|
| 30 |
|
| 31 |
# def send_results_to_api(data, result_url):
|
|
@@ -53,6 +54,7 @@ def process_images(params):
|
|
| 53 |
return {"error": "Missing required parameters: 'urls'"}
|
| 54 |
|
| 55 |
try:
|
|
|
|
| 56 |
images = [Image.open(requests.get(url, stream=True).raw) for url in image_urls] # images from URLs
|
| 57 |
except Exception as e:
|
| 58 |
logging.error(f"Error loading images: {e}")
|
|
@@ -60,10 +62,11 @@ def process_images(params):
|
|
| 60 |
|
| 61 |
names = detect_objects(images) # Perform object detection
|
| 62 |
solutions = create_solutions(image_urls, names) # Create solutions with image URLs and bounding boxes
|
|
|
|
| 63 |
|
| 64 |
# result_url = f"{api}/{job_id}"
|
| 65 |
# send_results_to_api(solutions, result_url)
|
| 66 |
-
|
| 67 |
return json.dumps({"solutions": solutions})
|
| 68 |
|
| 69 |
inputt = gr.Textbox(label="Parameters (JSON format) Eg. {'img_url':['a.jpg','b.jpg']}")
|
|
|
|
| 26 |
prediction_list.append(prediction)
|
| 27 |
obj = {"url": image_url, "answer": prediction_list, "qcUser" : None}
|
| 28 |
solutions.append(obj)
|
| 29 |
+
sprint("object prepared")
|
| 30 |
return solutions
|
| 31 |
|
| 32 |
# def send_results_to_api(data, result_url):
|
|
|
|
| 54 |
return {"error": "Missing required parameters: 'urls'"}
|
| 55 |
|
| 56 |
try:
|
| 57 |
+
print(f"operating on : {image_urls}")
|
| 58 |
images = [Image.open(requests.get(url, stream=True).raw) for url in image_urls] # images from URLs
|
| 59 |
except Exception as e:
|
| 60 |
logging.error(f"Error loading images: {e}")
|
|
|
|
| 62 |
|
| 63 |
names = detect_objects(images) # Perform object detection
|
| 64 |
solutions = create_solutions(image_urls, names) # Create solutions with image URLs and bounding boxes
|
| 65 |
+
print("prediction done")
|
| 66 |
|
| 67 |
# result_url = f"{api}/{job_id}"
|
| 68 |
# send_results_to_api(solutions, result_url)
|
| 69 |
+
print("solution sent")
|
| 70 |
return json.dumps({"solutions": solutions})
|
| 71 |
|
| 72 |
inputt = gr.Textbox(label="Parameters (JSON format) Eg. {'img_url':['a.jpg','b.jpg']}")
|