gaur3009 commited on
Commit
81f27f3
·
verified ·
1 Parent(s): d65a8bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -24
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
- from PIL import Image, ImageOps, ImageEnhance, ImageDraw
3
 
4
- def edit_image(image, grayscale, flip, rotate, brightness, contrast, color, color_picker, coordinates):
5
  img = Image.open(image)
6
  if grayscale:
7
  img = ImageOps.grayscale(img)
@@ -21,26 +21,9 @@ def edit_image(image, grayscale, flip, rotate, brightness, contrast, color, colo
21
  # Apply color
22
  enhancer = ImageEnhance.Color(img)
23
  img = enhancer.enhance(color)
24
-
25
- # Change color of selected area
26
- if coordinates:
27
- draw = ImageDraw.Draw(img)
28
- for coord in coordinates:
29
- draw.rectangle(coord, fill=color_picker, outline=None)
30
 
31
  return img
32
 
33
- def parse_coordinates(coordinate_str):
34
- coordinates = []
35
- if coordinate_str:
36
- for coord in coordinate_str.split(';'):
37
- try:
38
- x1, y1, x2, y2 = map(int, coord.split(','))
39
- coordinates.append((x1, y1, x2, y2))
40
- except ValueError:
41
- continue
42
- return coordinates
43
-
44
  interface = gr.Interface(
45
  fn=edit_image,
46
  inputs=[
@@ -50,14 +33,12 @@ interface = gr.Interface(
50
  gr.Slider(minimum=0, maximum=360, step=1, value=0, label="Rotate Angle"),
51
  gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Brightness"),
52
  gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Contrast"),
53
- gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Color"),
54
- gr.ColorPicker(label="Select Color"),
55
- gr.Textbox(label="Coordinates (x1,y1,x2,y2;...)", placeholder="Enter coordinates separated by semicolons")
56
  ],
57
  outputs=gr.Image(),
58
  live=True,
59
  title="Advanced Image Editor",
60
- description="Upload an image and apply various transformations including brightness, contrast, color adjustments, and change the color of specific areas."
61
  )
62
 
63
- interface.launch()
 
1
  import gradio as gr
2
+ from PIL import Image, ImageOps, ImageEnhance
3
 
4
+ def edit_image(image, grayscale, flip, rotate, brightness, contrast, color):
5
  img = Image.open(image)
6
  if grayscale:
7
  img = ImageOps.grayscale(img)
 
21
  # Apply color
22
  enhancer = ImageEnhance.Color(img)
23
  img = enhancer.enhance(color)
 
 
 
 
 
 
24
 
25
  return img
26
 
 
 
 
 
 
 
 
 
 
 
 
27
  interface = gr.Interface(
28
  fn=edit_image,
29
  inputs=[
 
33
  gr.Slider(minimum=0, maximum=360, step=1, value=0, label="Rotate Angle"),
34
  gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Brightness"),
35
  gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Contrast"),
36
+ gr.Slider(minimum=0.1, maximum=2, step=0.1, value=1, label="Color")
 
 
37
  ],
38
  outputs=gr.Image(),
39
  live=True,
40
  title="Advanced Image Editor",
41
+ description="Upload an image and apply various transformations including brightness, contrast, and color adjustments."
42
  )
43
 
44
+ interface.launch()