Spaces:
Running
Running
v3 to v4.
Browse files
app.py
CHANGED
@@ -5,12 +5,11 @@ import numpy as np
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import io
|
7 |
|
8 |
-
|
9 |
-
def inference(img, template, angel):
|
10 |
color_image = cv2.imread(img.name, cv2.IMREAD_COLOR)
|
11 |
|
12 |
HSV_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2HSV)
|
13 |
-
selected_harmomic_scheme = HarmonicScheme(str(template), int(
|
14 |
new_HSV_image = selected_harmomic_scheme.hue_shifted(HSV_image, num_superpixels=-1)
|
15 |
# Convert HSV to BGR
|
16 |
result_image = cv2.cvtColor(new_HSV_image, cv2.COLOR_HSV2BGR)
|
@@ -30,7 +29,6 @@ def inference(img, template, angel):
|
|
30 |
cv2.imwrite('hue.jpg', hue_plots)
|
31 |
cv2.imwrite('result_image.jpg', result_image)
|
32 |
|
33 |
-
|
34 |
return ['result_image.jpg', 'hue.jpg']
|
35 |
|
36 |
title = 'Color Harmonization'
|
@@ -41,16 +39,16 @@ examples = [['./examples/aim_interface.png', "V", 25], ['./examples/esfahan_unsp
|
|
41 |
|
42 |
gr.Interface(
|
43 |
inference,
|
44 |
-
[gr.
|
45 |
-
gr.
|
46 |
-
|
47 |
-
|
48 |
-
gr.
|
49 |
-
[gr.
|
50 |
-
gr.
|
51 |
title=title,
|
52 |
description=description,
|
53 |
article=article,
|
54 |
examples=examples,
|
55 |
# css=css,
|
56 |
-
).launch(debug=False, enable_queue=True)
|
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import io
|
7 |
|
8 |
+
def inference(img, template, angle):
|
|
|
9 |
color_image = cv2.imread(img.name, cv2.IMREAD_COLOR)
|
10 |
|
11 |
HSV_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2HSV)
|
12 |
+
selected_harmomic_scheme = HarmonicScheme(str(template), int(angle))
|
13 |
new_HSV_image = selected_harmomic_scheme.hue_shifted(HSV_image, num_superpixels=-1)
|
14 |
# Convert HSV to BGR
|
15 |
result_image = cv2.cvtColor(new_HSV_image, cv2.COLOR_HSV2BGR)
|
|
|
29 |
cv2.imwrite('hue.jpg', hue_plots)
|
30 |
cv2.imwrite('result_image.jpg', result_image)
|
31 |
|
|
|
32 |
return ['result_image.jpg', 'hue.jpg']
|
33 |
|
34 |
title = 'Color Harmonization'
|
|
|
39 |
|
40 |
gr.Interface(
|
41 |
inference,
|
42 |
+
[gr.Image(type='file', label='Original Image'),
|
43 |
+
gr.Dropdown(choices=["X", "Y", "T", "I", "mirror_L", "L", "V", "i"],
|
44 |
+
value="X",
|
45 |
+
label="Template"),
|
46 |
+
gr.Slider(0, 359, label="Angle")],
|
47 |
+
[gr.Image(type='file', label='Harmonized Image'),
|
48 |
+
gr.Image(type='file', label='Hue')],
|
49 |
title=title,
|
50 |
description=description,
|
51 |
article=article,
|
52 |
examples=examples,
|
53 |
# css=css,
|
54 |
+
).launch(debug=False, enable_queue=True)
|