Update app.py
Browse files
app.py
CHANGED
|
@@ -118,33 +118,37 @@ def process_image(image, transform_type):
|
|
| 118 |
(10, 30), cv2.FONT_HERSHEY_SIMPLEX,
|
| 119 |
0.7, (255, 255, 255), 2)
|
| 120 |
|
| 121 |
-
# Create analysis plots
|
| 122 |
-
plt.style.use('
|
| 123 |
fig, axes = plt.subplots(2, 2, figsize=(15, 12))
|
| 124 |
fig.suptitle('Blood Cell Analysis Results', fontsize=16, y=0.95)
|
| 125 |
|
| 126 |
df = pd.DataFrame(features)
|
| 127 |
if not df.empty:
|
| 128 |
# Distribution plots
|
| 129 |
-
|
| 130 |
axes[0,0].set_title('Cell Size Distribution')
|
| 131 |
axes[0,0].set_xlabel('Area (pixels)')
|
| 132 |
axes[0,0].set_ylabel('Count')
|
|
|
|
| 133 |
|
| 134 |
-
|
| 135 |
axes[0,1].set_title('Circularity Distribution')
|
| 136 |
axes[0,1].set_xlabel('Circularity')
|
| 137 |
axes[0,1].set_ylabel('Count')
|
|
|
|
| 138 |
|
| 139 |
# Scatter plot
|
| 140 |
axes[1,0].scatter(df['area'], df['circularity'], alpha=0.6, c='purple')
|
| 141 |
axes[1,0].set_title('Area vs Circularity')
|
| 142 |
axes[1,0].set_xlabel('Area')
|
| 143 |
axes[1,0].set_ylabel('Circularity')
|
|
|
|
| 144 |
|
| 145 |
# Box plot
|
| 146 |
df.boxplot(column=['area', 'circularity'], ax=axes[1,1])
|
| 147 |
axes[1,1].set_title('Feature Distributions')
|
|
|
|
| 148 |
else:
|
| 149 |
for ax in axes.flat:
|
| 150 |
ax.text(0.5, 0.5, 'No cells detected', ha='center', va='center')
|
|
@@ -163,6 +167,8 @@ def process_image(image, transform_type):
|
|
| 163 |
|
| 164 |
except Exception as e:
|
| 165 |
print(f"Error processing image: {str(e)}")
|
|
|
|
|
|
|
| 166 |
return None, None, None, None
|
| 167 |
|
| 168 |
|
|
|
|
| 118 |
(10, 30), cv2.FONT_HERSHEY_SIMPLEX,
|
| 119 |
0.7, (255, 255, 255), 2)
|
| 120 |
|
| 121 |
+
# Create analysis plots with default style
|
| 122 |
+
plt.style.use('default')
|
| 123 |
fig, axes = plt.subplots(2, 2, figsize=(15, 12))
|
| 124 |
fig.suptitle('Blood Cell Analysis Results', fontsize=16, y=0.95)
|
| 125 |
|
| 126 |
df = pd.DataFrame(features)
|
| 127 |
if not df.empty:
|
| 128 |
# Distribution plots
|
| 129 |
+
axes[0,0].hist(df['area'], bins=20, color='skyblue', edgecolor='black')
|
| 130 |
axes[0,0].set_title('Cell Size Distribution')
|
| 131 |
axes[0,0].set_xlabel('Area (pixels)')
|
| 132 |
axes[0,0].set_ylabel('Count')
|
| 133 |
+
axes[0,0].grid(True, alpha=0.3)
|
| 134 |
|
| 135 |
+
axes[0,1].hist(df['circularity'], bins=20, color='lightgreen', edgecolor='black')
|
| 136 |
axes[0,1].set_title('Circularity Distribution')
|
| 137 |
axes[0,1].set_xlabel('Circularity')
|
| 138 |
axes[0,1].set_ylabel('Count')
|
| 139 |
+
axes[0,1].grid(True, alpha=0.3)
|
| 140 |
|
| 141 |
# Scatter plot
|
| 142 |
axes[1,0].scatter(df['area'], df['circularity'], alpha=0.6, c='purple')
|
| 143 |
axes[1,0].set_title('Area vs Circularity')
|
| 144 |
axes[1,0].set_xlabel('Area')
|
| 145 |
axes[1,0].set_ylabel('Circularity')
|
| 146 |
+
axes[1,0].grid(True, alpha=0.3)
|
| 147 |
|
| 148 |
# Box plot
|
| 149 |
df.boxplot(column=['area', 'circularity'], ax=axes[1,1])
|
| 150 |
axes[1,1].set_title('Feature Distributions')
|
| 151 |
+
axes[1,1].grid(True, alpha=0.3)
|
| 152 |
else:
|
| 153 |
for ax in axes.flat:
|
| 154 |
ax.text(0.5, 0.5, 'No cells detected', ha='center', va='center')
|
|
|
|
| 167 |
|
| 168 |
except Exception as e:
|
| 169 |
print(f"Error processing image: {str(e)}")
|
| 170 |
+
import traceback
|
| 171 |
+
traceback.print_exc() # This will print the full error trace
|
| 172 |
return None, None, None, None
|
| 173 |
|
| 174 |
|