-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathligthedition.py
68 lines (52 loc) · 1.95 KB
/
ligthedition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
"""ligthEdition.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1y6lGi22s7FxqWt4uW7l1WmHJsp2YDh1f
# **Automatic Ligth ajust**
_________________________________________________________________________________________________________________________________________________________________________________________________________
Angel Toledo Flores<br>
Ingeniero Mecánico Agrícola/Ingeniero en Sistemas Computacionales.<br>
**E-mail**: contactoangeltoledo@gmail.com<br>
[Linkedin profile](https://www.linkedin.com/in/angel-toledo/) | [Portafolio de proyectos](https://resume.ingesaurio.com) <br>
[ DataSet: kagle](https://www.kaggle.com/code/shruthimshruthim/google-scrapped-image)
**`Just put the path of the image inside the inference function and enjoy the magic.`**
## Functions
"""
import cv2
from matplotlib.colors import hsv_to_rgb
import numpy as np
import matplotlib.pyplot as plt
def read_img(PATH):
"""
Read img and transform to HSV
"""
img = cv2.imread(PATH)
img = cv2.resize(img,(128,128))
hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV) / 255.0
return hsv
def inferencia(image_path):
"""
Obtein inferencie of the model
"""
image_hsv = read_img(image_path)
images = []
images.append(image_hsv[:,:,2])
images.append(image_hsv[:,:,2])
image_v = np.array(images)
np.shape(image_hsv)
predict_gama = model.predict(image_v)
VV = image_v[0]
print(np.shape(image_hsv))
print(np.shape(VV))
VV = VV.reshape((128,128))
image_hsv[:,:,2] = VV / predict_gama[0]
RGB_PREDICT = hsv_to_rgb(image_hsv)
plt.imshow(RGB_PREDICT)
plt.show()
"""## Import Model"""
from keras.models import load_model
!git clone https://github.com/toledoangel/automatic-image-brightness-adjustment.git
model = load_model('/content/automatic-image-brightness-adjustment/models/convPerceptronModel.h5')
"""## Inference"""
inferencia('/content/1002640661_c6adc3335c_m.jpg')