Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -14,48 +14,5 @@ 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 |
-
def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_scale, num_images_per_prompt, 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} {num_images_per_prompt} {model_precision_type} {seed} {output_image_name} {'--verbose' if verbose else ''}"
|
24 |
-
|
25 |
-
os.system(command)
|
26 |
-
|
27 |
-
|
28 |
-
return os.path.join(f"output_minecraft_skins/{output_image_name}")
|
29 |
-
|
30 |
-
|
31 |
-
# Define Gradio UI components
|
32 |
-
prompt_input = gr.Textbox(label="Your Prompt", info="What the Minecraft Skin should look like")
|
33 |
-
stable_diffusion_model_input = gr.Dropdown(['2', 'xl'], value="xl", label="Stable Diffusion Model", info="Choose which Stable Diffusion Model to use, xl understands prompts better")
|
34 |
-
num_inference_steps_input = gr.Number(label="Number of Inference Steps", precision=0, value=25)
|
35 |
-
guidance_scale_input = 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")
|
36 |
-
num_images_per_prompt_input = gr.Number(minimum=1, value=1, precision=0, label="Number of Images per Prompt", info="The number of images to make with the prompt")
|
37 |
-
model_precision_type_input = 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")
|
38 |
-
seed_input = gr.Number(value=42, label="Seed", info="A starting point to initiate generation, put 0 for a random one")
|
39 |
-
output_image_name_input = gr.Textbox(label="Output Image Name", info="The name of the file of the output image skin, keep the .png", value="output-skin.png")
|
40 |
-
verbose_input = gr.Checkbox(label="Verbose Output", info="Produce more detailed output while running", value=False)
|
41 |
-
|
42 |
-
|
43 |
-
# Create the Gradio interface
|
44 |
-
gr.Interface(
|
45 |
-
fn=run_inference,
|
46 |
-
inputs=[
|
47 |
-
prompt_input,
|
48 |
-
stable_diffusion_model_input,
|
49 |
-
num_inference_steps_input,
|
50 |
-
guidance_scale_input,
|
51 |
-
num_images_per_prompt_input,
|
52 |
-
model_precision_type_input,
|
53 |
-
seed_input,
|
54 |
-
output_image_name_input,
|
55 |
-
verbose_input
|
56 |
-
],
|
57 |
-
outputs=gr.Image(label="Generated Minecraft Skin Image Asset"),
|
58 |
-
title="Minecraft Skin Generator",
|
59 |
-
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)",
|
60 |
-
).launch(show_api=False, share=True)
|
61 |
|
|
|
|
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 |
+
subprocess.run([r"Run_Inference_UI.bat"] check=True, shell=True)
|