Shakir60 commited on
Commit
e7c0374
·
verified ·
1 Parent(s): 249fb68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -100,20 +100,19 @@ class ImageAnalyzer:
100
  ])
101
 
102
  def preprocess_image(self, image: Image.Image) -> Dict[str, Any]:
103
- """Enhanced image preprocessing with multiple analyses"""
104
- try:
105
- # Convert to RGB if necessary
106
- if image.mode != 'RGB':
107
- image = image.convert('RGB')
108
-
109
- # Basic image statistics
110
- img_array = np.array(image)
111
- stats = {
112
- "mean_brightness": np.mean(img_array),
113
- "std_brightness": np.std(img_array),
114
- "size": image.size,
115
- "aspect_ratio": image.size[0] / image.size[1]
116
- }
117
 
118
  # Edge detection for crack analysis
119
  gray = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
@@ -134,7 +133,7 @@ class ImageAnalyzer:
134
  "edges": edges,
135
  "rust_mask": rust_mask
136
  }
137
- except Exception as e:
138
  logger.error(f"Preprocessing error: {e}")
139
  return None
140
 
 
100
  ])
101
 
102
  def preprocess_image(self, image: Image.Image) -> Dict[str, Any]:
103
+ """Enhanced image preprocessing with multiple analyses"""
104
+ try:
105
+ # Convert to RGB if necessary
106
+ if image.mode != 'RGB':
107
+ image = image.convert('RGB')
108
+ # Basic image statistics
109
+ img_array = np.array(image)
110
+ stats = {
111
+ "mean_brightness": np.mean(img_array),
112
+ "std_brightness": np.std(img_array),
113
+ "size": image.size,
114
+ "aspect_ratio": image.size[0] / image.size[1]
115
+ }
 
116
 
117
  # Edge detection for crack analysis
118
  gray = cv2.cvtColor(img_array, cv2.COLOR_RGB2GRAY)
 
133
  "edges": edges,
134
  "rust_mask": rust_mask
135
  }
136
+ except Exception as e:
137
  logger.error(f"Preprocessing error: {e}")
138
  return None
139