Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,5 +14,44 @@ else:
|
|
| 14 |
subprocess.run(["git", "clone", "https://github.com/Nick088Official/Stable_Diffusion_Finetuned_Minecraft_Skin_Generator.git"])
|
| 15 |
os.chdir("Stable_Diffusion_Finetuned_Minecraft_Skin_Generator")
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
subprocess.run(["git", "clone", "https://github.com/Nick088Official/Stable_Diffusion_Finetuned_Minecraft_Skin_Generator.git"])
|
| 15 |
os.chdir("Stable_Diffusion_Finetuned_Minecraft_Skin_Generator")
|
| 16 |
|
| 17 |
+
def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_scale, model_precision_type, seed, output_image_name, verbose):
|
| 18 |
+
if stable_diffusion_model == '2':
|
| 19 |
+
sd_model = "minecraft-skins"
|
| 20 |
+
else:
|
| 21 |
+
sd_model = "minecraft-skins-sdxl"
|
| 22 |
|
| 23 |
+
command = f"python Python_Scripts/{sd_model}.py '{prompt}' {num_inference_steps} {guidance_scale} {model_precision_type} {seed} {output_image_name} {'--verbose' if verbose else ''}"
|
| 24 |
+
|
| 25 |
+
os.system(command)
|
| 26 |
+
|
| 27 |
+
return os.path.join(f"output_minecraft_skins/{output_image_name}")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# Define Gradio UI components
|
| 31 |
+
prompt = gr.Textbox(label="Your Prompt", info="What the Minecraft Skin should look like")
|
| 32 |
+
stable_diffusion_model = gr.Dropdown(['2', 'xl'], value="xl", label="Stable Diffusion Model", info="Choose which Stable Diffusion Model to use, xl understands prompts better")
|
| 33 |
+
num_inference_steps = gr.Number(label="Number of Inference Steps", precision=0, value=25)
|
| 34 |
+
guidance_scale = gr.Number(minimum=0.1, value=7.5, label="Guidance Scale", info="The number of denoising steps of the image. More denoising steps usually lead to a higher quality image at the cost of slower inference")
|
| 35 |
+
model_precision_type = gr.Dropdown(["fp16", "fp32"], value="fp16", label="Model Precision Type", info="The precision type to load the model, like fp16 which is faster, or fp32 which gives better results")
|
| 36 |
+
seed = gr.Number(value=42, label="Seed", info="A starting point to initiate generation, put 0 for a random one")
|
| 37 |
+
output_image_name = gr.Textbox(label="Output Image Name", info="The name of the file of the output image skin, keep the .png", value="output-skin.png")
|
| 38 |
+
verbose = gr.Checkbox(label="Verbose Output", info="Produce more detailed output while running", value=False)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
# Create the Gradio interface
|
| 42 |
+
gr.Interface(
|
| 43 |
+
fn=run_inference,
|
| 44 |
+
inputs=[
|
| 45 |
+
prompt,
|
| 46 |
+
stable_diffusion_model,
|
| 47 |
+
num_inference_steps,
|
| 48 |
+
guidance_scale,
|
| 49 |
+
model_precision_type,
|
| 50 |
+
seed,
|
| 51 |
+
output_image_name,
|
| 52 |
+
verbose
|
| 53 |
+
],
|
| 54 |
+
outputs=gr.Image(label="Generated Minecraft Skin Image Asset"),
|
| 55 |
+
title="Minecraft Skin Generator",
|
| 56 |
+
description="Make AI generated Minecraft Skins by a Finetuned Stable Diffusion Version!<br>Model used: https://github.com/Nick088Official/Stable_Diffusion_Finetuned_Minecraft_Skin_Generator<br>Hugging Face Space made by [Nick088](https://linktr.ee/Nick088)",
|
| 57 |
+
).launch(show_api=False, share=True)
|