Nick088 commited on
Commit
4aa0489
Β·
verified Β·
1 Parent(s): c33c9d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -41
app.py CHANGED
@@ -24,7 +24,8 @@ os.chdir("Stable_Diffusion_Finetuned_Minecraft_Skin_Generator")
24
 
25
  @spaces.GPU()
26
  def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_scale, model_precision_type, seed, filename, verbose, see_in_3d):
27
-
 
28
  if stable_diffusion_model == '2':
29
  sd_model = "minecraft-skins"
30
  else:
@@ -34,7 +35,7 @@ def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_
34
 
35
  os.system(inference_command)
36
 
37
- # view it in 3d
38
  if see_in_3d:
39
  os.chdir("Scripts")
40
  command_3d_model = f"python to_3d_model.py '{filename}'"
@@ -54,45 +55,28 @@ guidance_scale = gr.Number(minimum=0.1, value=7.5, label="Guidance Scale", info=
54
  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")
55
  seed = gr.Number(value=42, label="Seed", info="A starting point to initiate generation, put 0 for a random one")
56
  filename = gr.Textbox(label="Output Image Name", info="The name of the file of the output image skin, keep the.png", value="output-skin.png")
57
- verbose = gr.Checkbox(label="Verbose Output", info="Produce more detailed output while running", value=False)
58
  see_in_3d = gr.Checkbox(label="See in 3D", info="View the generated skin in 3D", value=False)
59
-
60
- title="<h1>Minecraft Skin Generator</h1>"
61
- 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>Credits: [Monadical-SAS](https://github.com/Monadical-SAS/minecraft_skin_generator) (Creators of the model), [Nick088](https://linktr.ee/Nick088) (Improving usage of the model), daroche (helping me fix the 3d model texture isue), [Brottweiler](https://gist.github.com/Brottweiler/483d0856c6692ef70cf90bf1a85ce364)(script to fix the 3d model texture, [meew](https://huggingface.co/spaces/meeww/Minecraft_Skin_Generator/blob/main/models/player_model.glb) (Minecraft Player 3d model)"
62
-
63
- with gr.Blocks() as demo:
64
- gr.Markdown(title)
65
- gr.Markdown(description)
66
- with gr.Column() as inference:
67
- inputs=[
68
- prompt,
69
- stable_diffusion_model,
70
- num_inference_steps,
71
- guidance_scale,
72
- model_precision_type,
73
- seed,
74
- filename,
75
- verbose,
76
- see_in_3d
77
- ]
78
-
79
- submit_btn = gr.Button("Submit")
80
-
81
-
82
- with gr.Column() as outputs:
83
- outputs=[
84
- gr.Image(label="Generated Minecraft Skin Image Asset"),
85
- gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model")
86
- ]
87
-
88
-
89
- submit_btn.click(
90
- run_inference,
91
- inputs,
92
- outputs,
93
- )
94
-
95
-
96
 
97
 
98
- demo.launch(show_api=False, share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  @spaces.GPU()
26
  def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_scale, model_precision_type, seed, filename, verbose, see_in_3d):
27
+
28
+ # inference
29
  if stable_diffusion_model == '2':
30
  sd_model = "minecraft-skins"
31
  else:
 
35
 
36
  os.system(inference_command)
37
 
38
+ # view it in 3d or not
39
  if see_in_3d:
40
  os.chdir("Scripts")
41
  command_3d_model = f"python to_3d_model.py '{filename}'"
 
55
  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")
56
  seed = gr.Number(value=42, label="Seed", info="A starting point to initiate generation, put 0 for a random one")
57
  filename = gr.Textbox(label="Output Image Name", info="The name of the file of the output image skin, keep the.png", value="output-skin.png")
 
58
  see_in_3d = gr.Checkbox(label="See in 3D", info="View the generated skin in 3D", value=False)
59
+ verbose = gr.Checkbox(label="Verbose Output", info="Produce more detailed output while running", value=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
 
62
+ # Create the Gradio interface
63
+ gr.Interface(
64
+ fn=run_inference,
65
+ inputs=[
66
+ prompt,
67
+ stable_diffusion_model,
68
+ num_inference_steps,
69
+ guidance_scale,
70
+ model_precision_type,
71
+ seed,
72
+ filename,
73
+ see_in_3d
74
+ verbose
75
+ ],
76
+ outputs=[
77
+ gr.Image(label="Generated Minecraft Skin Image Asset"),
78
+ gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model")
79
+ ],
80
+ title="Minecraft Skin Generator",
81
+ 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>Credits: [Monadical-SAS](https://github.com/Monadical-SAS/minecraft_skin_generator) (Creators of the model), [Nick088](https://linktr.ee/Nick088) (Improving usage of the model), daroche (helping me fix the 3d model texture isue), [Brottweiler](https://gist.github.com/Brottweiler/483d0856c6692ef70cf90bf1a85ce364)(script to fix the 3d model texture, [meew](https://huggingface.co/spaces/meeww/Minecraft_Skin_Generator/blob/main/models/player_model.glb) (Minecraft Player 3d model)",
82
+ ).launch(show_api=False, share=True)