Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,29 +60,26 @@ def gen(seed):
|
|
60 |
return imgArr
|
61 |
|
62 |
|
63 |
-
#
|
64 |
-
def
|
65 |
-
|
66 |
-
|
67 |
return gen(seed)
|
68 |
|
69 |
|
70 |
iface = gr.Interface(
|
71 |
-
fn=
|
72 |
inputs=[
|
73 |
-
gr.Text(label="Seed"
|
74 |
-
gr.Button("Surprise Me") # Add a "Surprise Me" button
|
75 |
],
|
76 |
outputs=gr.Gallery(label="Generated Skins"),
|
77 |
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
|
78 |
debug = True,
|
79 |
)
|
80 |
-
#
|
81 |
-
iface.add_component(
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
outputs=[gr.Gallery(label="Generated Skins")]
|
86 |
-
)
|
87 |
|
88 |
-
iface.launch(
|
|
|
60 |
return imgArr
|
61 |
|
62 |
|
63 |
+
# New function to handle text input or surprise me functionality
|
64 |
+
def handle_input(seed=None):
|
65 |
+
if seed is None or seed == "":
|
66 |
+
seed = random.randint(0, 1000)
|
67 |
return gen(seed)
|
68 |
|
69 |
|
70 |
iface = gr.Interface(
|
71 |
+
fn=handle_input,
|
72 |
inputs=[
|
73 |
+
gr.Text(label="Seed"), # Text input for seed
|
|
|
74 |
],
|
75 |
outputs=gr.Gallery(label="Generated Skins"),
|
76 |
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
|
77 |
debug = True,
|
78 |
)
|
79 |
+
# Adding a 'Surprise Me' button that does not require input and calls the same function without a seed
|
80 |
+
iface.add_component(gr.Button("Surprise Me"),
|
81 |
+
fn=lambda: handle_input(),
|
82 |
+
inputs=[],
|
83 |
+
outputs=iface.outputs)
|
|
|
|
|
84 |
|
85 |
+
iface.launch()
|