Spaces:
Runtime error

issef commited on
Commit
145a6bc
Β·
verified Β·
1 Parent(s): 22ec6dc

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +12 -7
  2. app.py +79 -0
  3. gitattributes +35 -0
  4. packages.txt +1 -0
  5. requirements.txt +8 -0
README.md CHANGED
@@ -1,12 +1,17 @@
1
  ---
2
- title: Test
3
- emoji: πŸ“‰
4
- colorFrom: blue
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 5.4.0
8
  app_file: app.py
9
- pinned: false
 
 
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Minecraft Skin Generator
3
+ emoji: πŸš€πŸŽ¨πŸ‘¨β€πŸ’Ό
4
+ colorFrom: green
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 4.36.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: gpl-3.0
11
+ short_description: Stable Diffusion Finetuned Version
12
+ models:
13
+ - monadical-labs/minecraft-skin-generator
14
+ - monadical-labs/minecraft-skin-generator-sdxl
15
  ---
16
 
17
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+ import gradio as gr
4
+ import torch
5
+ import numpy as np
6
+ from PIL import Image, ImageEnhance
7
+ import spaces
8
+
9
+
10
+ if torch.cuda.is_available():
11
+ device = "cuda"
12
+ print("Using GPU")
13
+ else:
14
+ device = "cpu"
15
+ print("Using CPU")
16
+
17
+
18
+ MAX_SEED = np.iinfo(np.int32).max
19
+
20
+
21
+ subprocess.run(["git", "clone", "https://github.com/Nick088Official/Stable_Diffusion_Finetuned_Minecraft_Skin_Generator.git"])
22
+
23
+ os.chdir("Stable_Diffusion_Finetuned_Minecraft_Skin_Generator")
24
+
25
+
26
+ @spaces.GPU(duration=75)
27
+ def run_inference(prompt, stable_diffusion_model, num_inference_steps, guidance_scale, model_precision_type, seed, filename, model_3d, verbose):
28
+
29
+ # inference
30
+ if stable_diffusion_model == '2':
31
+ sd_model = "minecraft-skins"
32
+ elif stable_diffusion_model == 'xl':
33
+ sd_model = "minecraft-skins-sdxl"
34
+
35
+ inference_command = f"python Scripts/{sd_model}.py '{prompt}' {num_inference_steps} {guidance_scale} {model_precision_type} {seed} {filename} {'--model_3d' if model_3d else ''} {'--verbose' if verbose else ''}"
36
+
37
+ os.system(inference_command)
38
+
39
+ # view it also as 3d model or not output
40
+ if model_3d:
41
+ return os.path.join(f"output_minecraft_skins/{filename}"), os.path.join(f"output_minecraft_skins/{filename}_3d_model.glb")
42
+ else:
43
+ return os.path.join(f"output_minecraft_skins/{filename}"), None
44
+
45
+
46
+ # Define Gradio UI components
47
+ prompt = gr.Textbox(label="Your Prompt", info="What the Minecraft Skin should look like")
48
+ 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")
49
+ num_inference_steps = gr.Slider(label="Number of Inference Steps", 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", minimum=1, maximum=50, value=25, step=1)
50
+ guidance_scale = gr.Slider(label="Guidance Scale", info="Controls how much the image generation process follows the text prompt. Higher values make the image stick more closely to the input text.", minimum=0.0, maximum=10.0, value=7.5, step=0.1)
51
+ 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 is more precise but more resource consuming")
52
+ seed = gr.Slider(value=42, minimum=0, maximum=MAX_SEED, step=1, label="Seed", info="A starting point to initiate the generation process, put 0 for a random one")
53
+ 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")
54
+ model_3d = gr.Checkbox(label="See as 3D Model too", info="View the generated skin as a 3D Model too", value=True)
55
+ verbose = gr.Checkbox(label="Verbose Output", info="Produce more detailed output while running", value=False)
56
+
57
+
58
+ # Create the Gradio interface
59
+ gr.Interface(
60
+ fn=run_inference,
61
+ inputs=[
62
+ prompt,
63
+ stable_diffusion_model,
64
+ num_inference_steps,
65
+ guidance_scale,
66
+ model_precision_type,
67
+ seed,
68
+ filename,
69
+ model_3d,
70
+ verbose
71
+ ],
72
+ outputs=[
73
+ gr.Image(label="Generated Minecraft Skin Image Asset", elem_classes="pixelated checkered"),
74
+ gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model View of the Skin")
75
+ ],
76
+ title="Minecraft Skin Generator",
77
+ description="Make AI generated Minecraft Skins by a Finetuned Stable Diffusion Version!<br>Github Repository & 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), [not-holar](https://huggingface.co/not-holar) (made the rendering of the image asset in the web ui look pixelated like minecraft and have a checkered background),[meew](https://huggingface.co/spaces/meeww/Minecraft_Skin_Generator/blob/main/models/player_model.glb) (Minecraft Player 3d model) <br> [![Discord](https://img.shields.io/discord/1198701940511617164?color=%23738ADB&label=Discord&style=for-the-badge)](https://discord.gg/AQsmBmgEPy)",
78
+ css=".pixelated {image-rendering: pixelated} .checkered img {background-image: url(\'data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"2\" height=\"2\" fill-opacity=\".15\"><rect x=\"1\" width=\"1\" height=\"1\"/><rect y=\"1\" width=\"1\" height=\"1\"/></svg>\');background-size: 16px;}"
79
+ ).launch(show_api=False, share=True)
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ imagemagick
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ diffusers
4
+ accelerate
5
+ gradio==4.36.0
6
+ scipy
7
+ Pillow===9.0.1
8
+ pygltflib