Spaces:
Running
Running
Commit
·
4f3074a
1
Parent(s):
db5f9ea
combine hues
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ def inference(img, template, angel):
|
|
| 12 |
HSV_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2HSV)
|
| 13 |
selected_harmomic_scheme = HarmonicScheme(str(template), int(angel))
|
| 14 |
new_HSV_image = selected_harmomic_scheme.hue_shifted(HSV_image, num_superpixels=-1)
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Compute shifted histogram
|
| 17 |
histo_1 = count_hue_histogram(HSV_image)
|
|
@@ -22,15 +24,14 @@ def inference(img, template, angel):
|
|
| 22 |
fig_1_cv = get_img_from_fig(fig1)
|
| 23 |
fig2 = plothis(histo_2, selected_harmomic_scheme, "Target Hue")
|
| 24 |
fig_2_cv = get_img_from_fig(fig2)
|
| 25 |
-
# Convert HSV to BGR
|
| 26 |
-
result_image = cv2.cvtColor(new_HSV_image, cv2.COLOR_HSV2BGR)
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
cv2.imwrite('result_image.jpg', result_image)
|
| 31 |
|
| 32 |
|
| 33 |
-
return ['result_image.jpg', '
|
| 34 |
|
| 35 |
title = 'Color Harmonization'
|
| 36 |
description = 'Compute Color Harmonization with Different Templates'
|
|
@@ -46,8 +47,7 @@ gr.Interface(
|
|
| 46 |
label="Template"),
|
| 47 |
gr.inputs.Slider(0, 359, label="Angle")],
|
| 48 |
[gr.outputs.Image(type='file', label='Color Harmonization of Output Image'),
|
| 49 |
-
gr.outputs.Image(type='file', label='
|
| 50 |
-
gr.outputs.Image(type='file', label='Target Hue'),],
|
| 51 |
title=title,
|
| 52 |
description=description,
|
| 53 |
article=article,
|
|
|
|
| 12 |
HSV_image = cv2.cvtColor(color_image, cv2.COLOR_BGR2HSV)
|
| 13 |
selected_harmomic_scheme = HarmonicScheme(str(template), int(angel))
|
| 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)
|
| 17 |
|
| 18 |
# Compute shifted histogram
|
| 19 |
histo_1 = count_hue_histogram(HSV_image)
|
|
|
|
| 24 |
fig_1_cv = get_img_from_fig(fig1)
|
| 25 |
fig2 = plothis(histo_2, selected_harmomic_scheme, "Target Hue")
|
| 26 |
fig_2_cv = get_img_from_fig(fig2)
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
hue_plots = np.concatenate((fig_1_cv, fig_2_cv), axis=1)
|
| 29 |
+
|
| 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'
|
| 37 |
description = 'Compute Color Harmonization with Different Templates'
|
|
|
|
| 47 |
label="Template"),
|
| 48 |
gr.inputs.Slider(0, 359, label="Angle")],
|
| 49 |
[gr.outputs.Image(type='file', label='Color Harmonization of Output Image'),
|
| 50 |
+
gr.outputs.Image(type='file', label='Hue'),
|
|
|
|
| 51 |
title=title,
|
| 52 |
description=description,
|
| 53 |
article=article,
|