Kvikontent commited on
Commit
1604608
·
verified ·
1 Parent(s): 63e9391

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import random
 
3
 
4
  def smooth_color(color, threshold):
5
  if color == " ":
@@ -40,9 +41,14 @@ def generate_color(prompt):
40
  color_green = smooth_color(color_green, len(greened))
41
  color_blue = smooth_color(color_blue, len(blued))
42
  color_white = smooth_color(color_white, len(whited))
43
- color_none = smooth_color(color_none, len(nothing))
44
 
45
- return "#" + color_red + color_green + color_blue + color_white + color_none
 
 
 
 
 
46
 
47
  iface = gr.Interface(generate_color, "text", "image", theme="soft")
48
  iface.launch()
 
1
  import gradio as gr
2
  import random
3
+ from PIL import Image, ImageDraw
4
 
5
  def smooth_color(color, threshold):
6
  if color == " ":
 
41
  color_green = smooth_color(color_green, len(greened))
42
  color_blue = smooth_color(color_blue, len(blued))
43
  color_white = smooth_color(color_white, len(whited))
44
+ color_none = smooth_color(color_none, len(nothing)
45
 
46
+ # Convert the color to an image using PIL
47
+ image = Image.new('RGB', (100, 100), color="#"+color_red+color_green+color_blue)
48
+ draw = ImageDraw.Draw(image)
49
+ draw.text((20, 40), "".join(whited), fill="#"+color_white)
50
+
51
+ return image
52
 
53
  iface = gr.Interface(generate_color, "text", "image", theme="soft")
54
  iface.launch()