Spaces:
Runtime error
Runtime error
Update app.py
Browse files59 unmodified lines606162636465666768697071727374757677787980818283848586878859 unmodified linesreturn imgArr# Function to generate a random seed and then generate imagesdef surprise_me():import randomseed = random.randint(0, 1000)return gen(seed)iface = gr.Interface(fn=gen,inputs=[gr.Text(label="Seed", default="500"), # Allow manual seed inputgr.Button("Surprise Me") # Add a "Surprise Me" button],outputs=gr.Gallery(label="Generated Skins"),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 WORKdebug = True,)# Define what happens when the "Surprise Me" button is clickediface.add_component(component=gr.Button("Surprise Me"),fn=surprise_me,inputs=[],outputs=[gr.Gallery(label="Generated Skins")])iface.launch(width=64,height=64,enable_queue=True)59 unmodified lines606162636465666768697071727374757677787980818283848559 unmodified linesreturn imgArr# New function to handle text input or surprise me functionalitydef handle_input(seed=None):if seed is None or seed == "":seed = random.randint(0, 1000)return gen(seed)iface = gr.Interface(fn=handle_input,inputs=[gr.Text(label="Seed"), # Text input for seed],outputs=gr.Gallery(label="Generated Skins"),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 WORKdebug = True,)# Adding a 'Surprise Me' button that does not require input and calls the same function without a seediface.add_component(gr.Button("Surprise Me"),fn=lambda: handle_input(),inputs=[],outputs=iface.outputs)iface.launch()
app.py+12-15