lampongyuen commited on
Commit
c7e3daf
·
1 Parent(s): 5bcf556

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -9
app.py CHANGED
@@ -1,24 +1,16 @@
1
  import gradio
2
  import cv2
3
- import numpy as np
4
 
5
  def greet(image, name, is_morning, temperature):
6
  salutation = "Good morning" if is_morning else "Good evening"
7
  greeting = f"{salutation} {name}. It is {temperature} degrees today"
8
  celsius = (temperature - 32) * 5 / 9
9
- print(image.shape)
10
- new_image = np.zeros(image.shape,image.dtype)
11
  # contrast [1.0-3.0]
12
  # brightness [0-100]
13
  # https://docs.opencv.org/4.x/d3/dc1/tutorial_basic_linear_transform.html
14
  in_contrast = 1.0
15
  in_brightness = 50
16
-
17
- for y in range(image.shape[0]):
18
- for x in range(image.shape[1]):
19
- for c in range(image.shape[2]):
20
- new_image[y,x,c] = np.clip(in_contrast*image[y,x,c] + in_brightness, 0, 255)
21
-
22
  return new_image, greeting, round(celsius, 2)
23
 
24
 
 
1
  import gradio
2
  import cv2
 
3
 
4
  def greet(image, name, is_morning, temperature):
5
  salutation = "Good morning" if is_morning else "Good evening"
6
  greeting = f"{salutation} {name}. It is {temperature} degrees today"
7
  celsius = (temperature - 32) * 5 / 9
 
 
8
  # contrast [1.0-3.0]
9
  # brightness [0-100]
10
  # https://docs.opencv.org/4.x/d3/dc1/tutorial_basic_linear_transform.html
11
  in_contrast = 1.0
12
  in_brightness = 50
13
+ new_image = cv.convertScaleAbs(image, alpha=in_contrast, beta=in_brightness)
 
 
 
 
 
14
  return new_image, greeting, round(celsius, 2)
15
 
16