D3V1L1810 commited on
Commit
d9ecb25
·
verified ·
1 Parent(s): 82a2458

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -5,6 +5,7 @@ import requests
5
  import json
6
  import logging
7
  import cv2
 
8
 
9
  logging.basicConfig(level=logging.INFO)
10
 
@@ -15,6 +16,7 @@ def detect_objects(images):
15
  classes={ 2: "Positive", 1: "Negative"}
16
  names = []
17
  for image in images:
 
18
  image = cv2.resize(image,(640,640))
19
  results_detection = model_detection(image)
20
 
@@ -87,7 +89,7 @@ def process_images(params):
87
  return {"error": "Missing required parameters: 'urls'"}
88
 
89
  try:
90
- images = [cv2.imread(requests.get(url, stream=True).raw,0) for url in image_urls] # images from URLs
91
  except Exception as e:
92
  logging.error(f"Error loading images: {e}")
93
  return {"error": f"Error loading images: {str(e)}"}
 
5
  import json
6
  import logging
7
  import cv2
8
+ from numpy import asarray
9
 
10
  logging.basicConfig(level=logging.INFO)
11
 
 
16
  classes={ 2: "Positive", 1: "Negative"}
17
  names = []
18
  for image in images:
19
+ image = asarray(image)
20
  image = cv2.resize(image,(640,640))
21
  results_detection = model_detection(image)
22
 
 
89
  return {"error": "Missing required parameters: 'urls'"}
90
 
91
  try:
92
+ images = [Image.open(requests.get(url, stream=True).raw) for url in image_urls] # images from URLs
93
  except Exception as e:
94
  logging.error(f"Error loading images: {e}")
95
  return {"error": f"Error loading images: {str(e)}"}