cr8 commited on
Commit
5ec77f2
·
verified ·
1 Parent(s): 4615b2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -20
app.py CHANGED
@@ -1,31 +1,27 @@
1
- import torch
2
  import gradio as gr
3
- from PIL import Image
4
- from transformers import AutoImageProcessor, AutoModelForImageProcessing
5
 
6
- # Load model and processor
7
- processor = AutoImageProcessor.from_pretrained("eugenesiow/EnhanceNet")
8
- model = AutoModelForImageProcessing.from_pretrained("eugenesiow/EnhanceNet").to('cpu')
9
-
10
- def enhance_image(image):
11
- # Convert PIL Image to tensor
12
- inputs = processor(images=image, return_tensors="pt").to('cpu')
13
 
14
- # Forward pass
15
- with torch.no_grad():
16
- outputs = model(**inputs)
17
 
18
- # Convert tensor back to PIL Image
19
- enhanced_image = processor.post_process_output(outputs.pixel_values)
20
- return enhanced_image[0]
21
 
22
  # Gradio Interface
23
  iface = gr.Interface(
24
- fn=enhance_image,
25
- inputs=gr.Image(type="pil", label="Upload Dull Image"),
26
  outputs=gr.Image(type="pil", label="Vibrant Image"),
27
- title="Dull to Vibrant Image Enhancer",
28
- description="Enhance dull images using EnhanceNet on CPU. For faster GPU processing, duplicate this Space and enable GPU in settings."
29
  )
30
 
31
  if __name__ == "__main__":
 
 
1
  import gradio as gr
2
+ from PIL import Image, ImageEnhance
 
3
 
4
+ def enhance_vibrancy(image):
5
+ # Convert to RGB if needed
6
+ image = image.convert("RGB")
7
+
8
+ # Enhance color saturation
9
+ enhancer = ImageEnhance.Color(image)
10
+ vibrant_image = enhancer.enhance(2.0) # 2.0x saturation
11
 
12
+ # Enhance brightness slightly
13
+ enhancer = ImageEnhance.Brightness(vibrant_image)
14
+ vibrant_image = enhancer.enhance(1.2)
15
 
16
+ return vibrant_image
 
 
17
 
18
  # Gradio Interface
19
  iface = gr.Interface(
20
+ fn=enhance_vibrancy,
21
+ inputs=gr.Image(type="pil", label="Original Image"),
22
  outputs=gr.Image(type="pil", label="Vibrant Image"),
23
+ title="Simple Image Vibrancy Booster",
24
+ description="Enhance image vibrancy using basic color adjustments (no AI involved)"
25
  )
26
 
27
  if __name__ == "__main__":