Spaces:
Sleeping
Sleeping
Add examples
Browse files
.gitattributes
CHANGED
|
@@ -34,3 +34,7 @@ saved_model/**/* 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
|
| 36 |
example.png 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
|
| 36 |
example.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
example/aerial_rocks_02_diff_4k_Displacement.jpg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
example/aerial_rocks_02_diff_4k_Normal.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
example/aerial_rocks_02_diff_4k_Roughness.jpg filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
example/aerial_rocks_02_diff_4k.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -277,14 +277,13 @@ def load_models():
|
|
| 277 |
def process_image(img, model):
|
| 278 |
"""Process a single image through the model."""
|
| 279 |
img = np.array(img).astype(np.float32) / 255.0
|
| 280 |
-
if len(img.shape) == 2:
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
return (output * 255).astype(np.uint8)
|
| 288 |
|
| 289 |
def generate_maps(input_image):
|
| 290 |
"""Generate Normal, Roughness, and Displacement maps from input diffuse texture."""
|
|
@@ -318,4 +317,4 @@ if __name__ == "__main__":
|
|
| 318 |
rough_out = gr.Image(label="Roughness", height=180)
|
| 319 |
disp_out = gr.Image(label="Displacement", height=180)
|
| 320 |
btn.click(fn=generate_maps, inputs=input_img, outputs=[normal_out, rough_out, disp_out])
|
| 321 |
-
demo.launch(theme=gr.themes.Soft())
|
|
|
|
| 277 |
def process_image(img, model):
|
| 278 |
"""Process a single image through the model."""
|
| 279 |
img = np.array(img).astype(np.float32) / 255.0
|
| 280 |
+
if len(img.shape) == 2: img = np.stack([img, img, img], axis=-1)
|
| 281 |
+
if img.shape[2] == 4: img = img[:, :, :3]
|
| 282 |
+
tensor = torch.from_numpy(np.transpose(img.copy(), (2, 0, 1))).float().unsqueeze(0)
|
| 283 |
+
with torch.inference_mode():
|
| 284 |
+
output = model(tensor).squeeze(0).clamp_(0, 1).numpy()
|
| 285 |
+
del tensor # Explicit cleanup
|
| 286 |
+
return (np.transpose(output, (1, 2, 0)) * 255).astype(np.uint8)
|
|
|
|
| 287 |
|
| 288 |
def generate_maps(input_image):
|
| 289 |
"""Generate Normal, Roughness, and Displacement maps from input diffuse texture."""
|
|
|
|
| 317 |
rough_out = gr.Image(label="Roughness", height=180)
|
| 318 |
disp_out = gr.Image(label="Displacement", height=180)
|
| 319 |
btn.click(fn=generate_maps, inputs=input_img, outputs=[normal_out, rough_out, disp_out])
|
| 320 |
+
demo.launch(theme=gr.themes.Soft(), ssr_mode=False)
|
example/aerial_rocks_02_diff_4k.jpg
ADDED
|
Git LFS Details
|
example/aerial_rocks_02_diff_4k_Displacement.jpg
ADDED
|
Git LFS Details
|
example/aerial_rocks_02_diff_4k_Normal.jpg
ADDED
|
Git LFS Details
|
example/aerial_rocks_02_diff_4k_Roughness.jpg
ADDED
|
Git LFS Details
|