EntropyDrop commited on
Commit
b9af2c2
·
1 Parent(s): 5bbe62a
Files changed (1) hide show
  1. README.md +149 -1
README.md CHANGED
@@ -1,3 +1,151 @@
1
- ## License
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
 
1
+ # Sking: Minecraft Skin 3D Rendering & Dataset Preprocessing Pipeline
2
+
3
+ This repository is the official home of the **Sking Model Dataset** (hosted on [Hugging Face Datasets](https://huggingface.co/datasets/EntropyDrop/Sking)), which is utilized for training and fine-tuning the **Sking Model** ([Hugging Face Model](https://huggingface.co/EntropyDrop/Sking)).
4
+
5
+ Along with the dataset assets, it contains the complete automated pipeline for dual-layer 3D voxel rendering, multi-view layout baking, automatic skin format conversion (Alex to Steve), voxel edge texture consistency resolution, and a RESTful FastAPI service for extracting the actual usable 64x64 RGBA skin UV map from composite training targets.
6
+
7
+ ---
8
+
9
+ ## 🔗 Resources
10
+
11
+ * **🗂️ Dataset**: [Hugging Face Sking Dataset](https://huggingface.co/datasets/EntropyDrop/Sking)
12
+ * **🧠 Trained Model**: [Hugging Face Sking Model](https://huggingface.co/EntropyDrop/Sking)
13
+ * **📝 Technical Report**: [SkinGen Governance & Technical Architecture](https://entropydrop.com/skin/open/article/skingen)
14
+ * **🌐 Online Demo**: [EntropyDrop Web Portal](https://entropydrop.com)
15
+
16
+ ---
17
+
18
+ ## 🚀 Key Features
19
+
20
+ * **🎮 3D Voxel Rendering (`mc_render.py`)**
21
+ - Powered by `PyVista` (VTK) to translate 2D skin textures into 3D voxel character meshes.
22
+ - Supports dual-layer rendering: Core layer (base body) and Decor layer (jacket, sleeves, pants, hat).
23
+ - Fully parameterizable limb articulation supporting rotation (Pitch/Yaw/Roll) and spatial offset configurations.
24
+ - Interactive lighting mode with real-time viewport keyboard controls (W/S/A/D/Q/E for light position, R/F for intensity).
25
+ - Supports orthographic and perspective projections, wireframe overlays, custom backgrounds, and alpha-transparent exports.
26
+
27
+ * **🧩 Voxel Texture Consistency Resolver (`mc_voxel_texture_resolver.py`)**
28
+ - Solves the visual gap artifact caused by transparent adjacent faces in dual-layer skins during 3D voxelization.
29
+ - Implements a 3D voxel projection mapping algorithm that automatically fills missing/transparent adjacent faces according to a priority sequence (`Front -> Back -> Top -> Bottom -> Left -> Right`) for 3D renders.
30
+
31
+ * **🔄 Layout Standardization: Alex-to-Steve (`alice_to_steve.py`)**
32
+ - Automatically detects slim-armed (Alex, 3px arm width) skin formats.
33
+ - Applies a pixel-column projection and replication mapping to expand slim arms to standard (Steve, 4px arm width) format to standardize features across the dataset.
34
+
35
+ * **📸 Multi-View Layout Baking (`build_target_img.py`)**
36
+ - Upsamples 64x64 flat textures via box filtering and injects 2x2 white indicators on background regions to represent alpha transparency values as conditioning cues for generative models.
37
+ - Bakes a composite layout image at `768x768` resolution featuring the 2D skin texture along with **17 distinct, pre-configured 3D render viewports** (incorporating walking, idle, back-view, close-ups, and layer-toggled angles).
38
+
39
+ * **⚡ Batch Processing Pipeline (`build_target_imgs.py`)**
40
+ - Leverages a multi-threaded execution pool (`ThreadPoolExecutor`) managing isolated sub-processes for batch rendering.
41
+ - Supports parallel processing on multi-core systems.
42
+
43
+ * **🔓 Skin UV Map Extraction (`extract_skin.py`)**
44
+ - **Extraction Engine**: Crops and extracts the actual usable 64x64 skin UV map from the 2D layout area of synthesized training target images, resolving alpha transparency indicators to recover clean texture maps.
45
+ - **FastAPI Microservice**: Exposes the UV map extractor as a REST API alongside its command-line execution mode.
46
+
47
+ * **📐 Conditioning Image Formatting (`force_resize_control_imgs.py`)**
48
+ - Automatically resamples and centers control images inside a standard `1024x1024` alpha-transparent canvas utilizing Lanczos interpolation, ensuring compatibility with advanced ControlNet training frameworks.
49
+
50
+ ---
51
+
52
+ ## 📂 Project Structure
53
+
54
+ ```bash
55
+ Sking/
56
+ ├── mc_render.py # Core 3D engine (PyVista viewport & headless off-screen rendering)
57
+ ├── mc_voxel_texture_resolver.py # Voxel texture patcher & visual difference analyzer
58
+ ├── alice_to_steve.py # Alex-to-Steve (3px-to-4px arm width) mapping algorithm
59
+ ├── build_target_img.py # Single-skin multi-view layout baker (generates 768x768 composite)
60
+ ├── build_target_imgs.py # Concurrent batch rendering pipeline
61
+ ├── extract_skin.py # Skin UV map extraction CLI & FastAPI server
62
+ ├── force_resize_control_imgs.py # Control map resampling & canvas standardization (1024x1024)
63
+ ├── skin-mask.png # Pixel-level spatial mapping mask for Core layer
64
+ ├── skin-decor-mask.png # Pixel-level spatial mapping mask for Decor layer
65
+ ├── skins/ # Directory for raw input skins (.png)
66
+ ├── target_imgs_v73/ # Output directory for baked multi-view layouts
67
+ └── control_imgs/ # Processing directory for conditioning control maps
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 🛠️ System Requirements & Installation
73
+
74
+ ### 1. Prerequisites
75
+ - Python 3.8 or higher.
76
+ - A virtual environment configuration is highly recommended.
77
+
78
+ ### 2. Installation
79
+ Install all required packages:
80
+ ```bash
81
+ pip install pyvista numpy pillow fastapi uvicorn opencv-python pydantic
82
+ ```
83
+ > **Note for Headless Environments**: Since `PyVista` utilizes VTK under the hood, running it on headless servers (e.g., Linux instances without GUI support) requires a virtual frame buffer configuration. Please wrap the execution using a utility like `xvfb-run`.
84
+
85
+ ---
86
+
87
+ ## 📖 Command Line & API Reference
88
+
89
+ ### A. Bake Multi-View Layout for a Single Skin
90
+ ```bash
91
+ python build_target_img.py skins/steve.png target_imgs_v73/steve.png
92
+ ```
93
+ This utility automatically executes the following pipeline sequence:
94
+ 1. Validates texture dimension (64x64) and format integrity (RGBA).
95
+ 2. Performs slim-arm check and converts Alex formats to Steve formats dynamically if needed.
96
+ 3. Patches voxel edge-transparency conflicts.
97
+ 4. Generates a `768x768` composite layout containing the 2D layout and 17 distinct 3D viewports.
98
+
99
+ ### B. Batch Processing
100
+ ```bash
101
+ python build_target_imgs.py
102
+ ```
103
+ Batch scans the `skins/` directory and processes them concurrently using parallel workers, exporting the output files into `target_imgs_v73/`.
104
+
105
+ ### C. Interactive 3D Rendering & Viewing
106
+ To examine or visually debug the 3D rendering configuration of a specific skin:
107
+ ```bash
108
+ python mc_render.py skins/my_skin.png --interact
109
+ ```
110
+ - **Real-Time Light Position & Intensity Keyboard Controls**:
111
+ - `W` / `S`: Translate light position along the Z-axis (Forward / Backward).
112
+ - `A` / `D`: Translate light position along the X-axis (Left / Right).
113
+ - `Q` / `E`: Translate light position along the Y-axis (Up / Down).
114
+ - `R` / `F`: Increment / Decrement light intensity.
115
+ - `P`: Print current light coordinate vector and intensity scalar to terminal output.
116
+ - **Custom Articulation & Off-Screen Export Example**:
117
+ ```bash
118
+ python mc_render.py skins/my_skin.png --rot-head 15 30 0 --rot-arm-right -45 0 0 --save output.png
119
+ ```
120
+
121
+ ### D. Skin UV Map Extraction API
122
+ #### CLI Execution Mode
123
+ ```bash
124
+ python extract_skin.py --img target_imgs_v73/steve.png --output restored_steve.png
125
+ ```
126
+ #### API Server Mode
127
+ Run the FastAPI microservice:
128
+ ```bash
129
+ python extract_skin.py --server True
130
+ ```
131
+ The microservice launches locally on `http://0.0.0.0:10010`.
132
+
133
+ - **Endpoint**: `POST /extract`
134
+ - **Request Body Format**:
135
+ ```json
136
+ {
137
+ "img": "<base64_encoded_synthesized_image>"
138
+ }
139
+ ```
140
+ - **Response Body Format**:
141
+ ```json
142
+ {
143
+ "img": "<base64_encoded_64x64_restored_skin_png>"
144
+ }
145
+ ```
146
+
147
+ ---
148
+
149
+ ## 📄 License
150
 
151
  This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](LICENSE) file for details.