Spaces:
Runtime error
Runtime error
Commit
·
c8d4b55
1
Parent(s):
ca529d5
app update
Browse files
app.py
CHANGED
|
@@ -27,22 +27,26 @@ def switch_color(color_style):
|
|
| 27 |
is_light = True
|
| 28 |
elif color_style == "dark":
|
| 29 |
is_light = False
|
| 30 |
-
back_color_ = random_color(is_light)
|
| 31 |
-
back_color = RGB_to_Hex(back_color_)
|
| 32 |
|
| 33 |
# Draw color pictures.
|
| 34 |
-
w, h =
|
| 35 |
img = np.zeros((h, w, 3), np.uint8)
|
| 36 |
cv2.rectangle(img, (0, 0), (w, h), back_color_, thickness=-1)
|
| 37 |
|
| 38 |
-
return back_color, img
|
| 39 |
|
| 40 |
|
| 41 |
inputs = [gr.Radio(["light", "dark"], value="light")]
|
| 42 |
|
| 43 |
-
outputs = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
title = "Color
|
| 46 |
description = (
|
| 47 |
"Click the Submit button, and a dark or light color will be randomly generated."
|
| 48 |
)
|
|
@@ -52,7 +56,7 @@ demo = gr.Interface(
|
|
| 52 |
inputs=inputs,
|
| 53 |
outputs=outputs,
|
| 54 |
title=title,
|
| 55 |
-
description=description
|
| 56 |
)
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
|
|
|
| 27 |
is_light = True
|
| 28 |
elif color_style == "dark":
|
| 29 |
is_light = False
|
| 30 |
+
back_color_ = random_color(is_light) # Randomly generate colors
|
| 31 |
+
back_color = RGB_to_Hex(back_color_) # Convert to hexadecimal
|
| 32 |
|
| 33 |
# Draw color pictures.
|
| 34 |
+
w, h = 50, 50
|
| 35 |
img = np.zeros((h, w, 3), np.uint8)
|
| 36 |
cv2.rectangle(img, (0, 0), (w, h), back_color_, thickness=-1)
|
| 37 |
|
| 38 |
+
return back_color, back_color, img
|
| 39 |
|
| 40 |
|
| 41 |
inputs = [gr.Radio(["light", "dark"], value="light")]
|
| 42 |
|
| 43 |
+
outputs = [
|
| 44 |
+
gr.ColorPicker(label="color"),
|
| 45 |
+
gr.Textbox(label="hexadecimal color"),
|
| 46 |
+
gr.Image(type="numpy", label="color picture"),
|
| 47 |
+
]
|
| 48 |
|
| 49 |
+
title = "Color Generator"
|
| 50 |
description = (
|
| 51 |
"Click the Submit button, and a dark or light color will be randomly generated."
|
| 52 |
)
|
|
|
|
| 56 |
inputs=inputs,
|
| 57 |
outputs=outputs,
|
| 58 |
title=title,
|
| 59 |
+
description=description,
|
| 60 |
)
|
| 61 |
|
| 62 |
if __name__ == "__main__":
|