Almahfouz commited on
Commit
1cb4716
·
verified ·
1 Parent(s): f8753ba

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image, ImageEnhance
3
+
4
+ # Function to convert image to grayscale and adjust brightness
5
+ def process_image(image, brightness):
6
+ # Convert the image to grayscale
7
+ grayscale_image = image.convert("L")
8
+
9
+ # Adjust the brightness
10
+ enhancer = ImageEnhance.Brightness(grayscale_image)
11
+ bright_image = enhancer.enhance(brightness)
12
+
13
+ return bright_image
14
+
15
+ # Create a Gradio interface
16
+ iface = gr.Interface(
17
+ fn=process_image, # Function to process the image
18
+ inputs=[
19
+ gr.Image(type="pil"), # Image input, type is PIL (Python Imaging Library)
20
+ gr.Slider(0.1, 2.0, 1.0, label="Brightness") # Slider to control brightness
21
+ ],
22
+ outputs="image", # Output is an image
23
+ title="Grayscale Image Processor", # Title of the interface
24
+ description="Upload an image, convert it to grayscale, and adjust the brightness." # Description
25
+ )
26
+
27
+ # Launch the interface
28
+ iface.launch()