meeww commited on
Commit
1983f04
·
verified ·
1 Parent(s): f6fed66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -49,7 +49,7 @@ init()
49
 
50
 
51
  def gen(seed=None):
52
- if seed is None or seed == "Surprise Me":
53
  seed = random.randint(0, 1000)
54
  else:
55
  seed = int(seed)
@@ -61,15 +61,17 @@ def gen(seed=None):
61
  img = Image.open(f"{i}.png").convert('RGB')
62
  img = img.resize((64, 64), Image.NEAREST)
63
  imgArr.append(img)
64
- return imgArr
65
 
66
 
67
  # Function to handle the input from the interface
68
  def handle_input(seed_text, surprise_me):
69
  if surprise_me:
70
- return gen("Surprise Me")
71
  else:
72
- return gen(seed_text)
 
 
73
 
74
 
75
 
@@ -79,7 +81,10 @@ iface = gr.Interface(
79
  gr.Text(label="Seed", placeholder="Enter a seed"), # Text input for seed
80
  gr.Checkbox(label="Surprise Me", value=False), # Checkbox for 'Surprise Me' functionality
81
  ],
82
- outputs=gr.Gallery(label="Generated Skins"),
 
 
 
83
  title = "Minecraft Skin Generator <style>img{image-rendering: pixelated;}</style>", #<-- EWW GROSS IK IK IM SORRY, BUT THAT'S THE ONLY WAY I FOUND IT TO WORK
84
  debug = True,
85
  )
 
49
 
50
 
51
  def gen(seed=None):
52
+ if seed is None or seed == "Surprise Me" or seed == "":
53
  seed = random.randint(0, 1000)
54
  else:
55
  seed = int(seed)
 
61
  img = Image.open(f"{i}.png").convert('RGB')
62
  img = img.resize((64, 64), Image.NEAREST)
63
  imgArr.append(img)
64
+ return imgArr, seed # Return both images and the seed used
65
 
66
 
67
  # Function to handle the input from the interface
68
  def handle_input(seed_text, surprise_me):
69
  if surprise_me:
70
+ images, used_seed = gen("Surprise Me")
71
  else:
72
+ images, used_seed = gen(seed_text)
73
+ return images, f"Seed Used: {used_seed}" # Provide feedback on the used seed
74
+
75
 
76
 
77
 
 
81
  gr.Text(label="Seed", placeholder="Enter a seed"), # Text input for seed
82
  gr.Checkbox(label="Surprise Me", value=False), # Checkbox for 'Surprise Me' functionality
83
  ],
84
+ outputs=[
85
+ gr.Gallery(label="Generated Skins"), # Display generated images
86
+ gr.Textbox(label="Used Seed", readonly=True) # Display the seed used to generate the images
87
+ ],
88
  title = "Minecraft Skin Generator <style>img{image-rendering: pixelated;}</style>", #<-- EWW GROSS IK IK IM SORRY, BUT THAT'S THE ONLY WAY I FOUND IT TO WORK
89
  debug = True,
90
  )