Ashrafb commited on
Commit
3ef541a
·
verified ·
1 Parent(s): 353ac64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -29
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import tensorflow as tf
3
  import tensorflow_hub as hub
4
  import numpy as np
5
- from PIL import Image, ImageEnhance, ImageFilter
6
  from rembg import remove
7
 
8
  # Load the neural style transfer model from TensorFlow Hub
@@ -46,30 +46,6 @@ def apply_style_transfer(content_image, style_image, intensity=1.0):
46
 
47
  return tensor_to_image(stylized_image)
48
 
49
- # Function to enhance the image to make it glistening
50
- def enhance_image(image):
51
- # Convert to Image for processing
52
- if isinstance(image, np.ndarray):
53
- image = Image.fromarray(image)
54
-
55
- # Enhance color
56
- enhancer = ImageEnhance.Color(image)
57
- image = enhancer.enhance(1.5) # Increase color saturation
58
-
59
- # Enhance contrast
60
- enhancer = ImageEnhance.Contrast(image)
61
- image = enhancer.enhance(1.3) # Increase contrast
62
-
63
- # Apply a slight blur to simulate glow
64
- image = image.filter(ImageFilter.GaussianBlur(radius=2))
65
-
66
- # Optionally add noise (uncomment to use)
67
- # noise = np.random.normal(0, 25, (image.height, image.width, 3))
68
- # noise_image = np.array(image) + noise
69
- # image = Image.fromarray(np.clip(noise_image, 0, 255).astype(np.uint8))
70
-
71
- return image
72
-
73
  # Function to process image
74
  def process_image(content_image, style_image):
75
  # Ensure style_image is a PIL Image
@@ -101,10 +77,7 @@ def process_image(content_image, style_image):
101
 
102
  combined_image = Image.fromarray(np.clip(combined_image_np, 0, 255).astype(np.uint8))
103
 
104
- # Apply enhancement to make it glistening
105
- enhanced_image = enhance_image(combined_image)
106
-
107
- return enhanced_image
108
 
109
  # Gradio interface setup
110
  image1 = gr.Image(label="Content Image")
 
2
  import tensorflow as tf
3
  import tensorflow_hub as hub
4
  import numpy as np
5
+ from PIL import Image
6
  from rembg import remove
7
 
8
  # Load the neural style transfer model from TensorFlow Hub
 
46
 
47
  return tensor_to_image(stylized_image)
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  # Function to process image
50
  def process_image(content_image, style_image):
51
  # Ensure style_image is a PIL Image
 
77
 
78
  combined_image = Image.fromarray(np.clip(combined_image_np, 0, 255).astype(np.uint8))
79
 
80
+ return combined_image
 
 
 
81
 
82
  # Gradio interface setup
83
  image1 = gr.Image(label="Content Image")