Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ def convert_to_sketch(img, blur_strength, brightness, contrast):
|
|
16 |
img = np.array(img)
|
17 |
|
18 |
# Convert the image to grayscale
|
19 |
-
img_gray = cv2.cvtColor(img, cv2.
|
20 |
|
21 |
# Invert the grayscale image
|
22 |
img_inverted = cv2.bitwise_not(img_gray)
|
@@ -49,15 +49,9 @@ def sketch_interface(image, blur_strength, brightness, contrast):
|
|
49 |
# Convert the input image to a sketch with adjustments
|
50 |
sketch = convert_to_sketch(image, blur_strength, brightness, contrast)
|
51 |
|
52 |
-
#
|
53 |
output_image = Image.fromarray(sketch)
|
54 |
|
55 |
-
# Check if the image was properly created
|
56 |
-
if output_image:
|
57 |
-
print("Image processed successfully!")
|
58 |
-
else:
|
59 |
-
print("Failed to process image!")
|
60 |
-
|
61 |
# Return the processed sketch image
|
62 |
return output_image
|
63 |
|
|
|
16 |
img = np.array(img)
|
17 |
|
18 |
# Convert the image to grayscale
|
19 |
+
img_gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) # Use RGB2GRAY for PIL images
|
20 |
|
21 |
# Invert the grayscale image
|
22 |
img_inverted = cv2.bitwise_not(img_gray)
|
|
|
49 |
# Convert the input image to a sketch with adjustments
|
50 |
sketch = convert_to_sketch(image, blur_strength, brightness, contrast)
|
51 |
|
52 |
+
# Convert the processed numpy array back to a PIL Image
|
53 |
output_image = Image.fromarray(sketch)
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
# Return the processed sketch image
|
56 |
return output_image
|
57 |
|