Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,23 @@ import numpy as np
|
|
3 |
import gradio as gr
|
4 |
|
5 |
def load_image(path):
|
|
|
6 |
return skia.Image.open(path)
|
7 |
|
8 |
def save_image(image, path):
|
|
|
9 |
image.save(path)
|
10 |
|
11 |
def image_to_array(image):
|
|
|
12 |
return np.array(image)
|
13 |
|
14 |
def array_to_image(array):
|
|
|
15 |
return skia.Image.fromarray(np.uint8(array))
|
16 |
|
17 |
def texture_image_with_normal(A, A_normal, B):
|
|
|
18 |
# Load images
|
19 |
A_img = load_image(A)
|
20 |
A_normal_img = load_image(A_normal)
|
@@ -57,6 +62,7 @@ def texture_image_with_normal(A, A_normal, B):
|
|
57 |
return textured_image
|
58 |
|
59 |
def gradio_interface(A, A_normal, B):
|
|
|
60 |
textured_image = texture_image_with_normal(A, A_normal, B)
|
61 |
return np.array(textured_image)
|
62 |
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
def load_image(path):
|
6 |
+
"""Load an image from the given path using Skia."""
|
7 |
return skia.Image.open(path)
|
8 |
|
9 |
def save_image(image, path):
|
10 |
+
"""Save the given image to the specified path."""
|
11 |
image.save(path)
|
12 |
|
13 |
def image_to_array(image):
|
14 |
+
"""Convert a Skia image to a numpy array."""
|
15 |
return np.array(image)
|
16 |
|
17 |
def array_to_image(array):
|
18 |
+
"""Convert a numpy array to a Skia image."""
|
19 |
return skia.Image.fromarray(np.uint8(array))
|
20 |
|
21 |
def texture_image_with_normal(A, A_normal, B):
|
22 |
+
"""Texture image B onto image A based on the normal map A_normal."""
|
23 |
# Load images
|
24 |
A_img = load_image(A)
|
25 |
A_normal_img = load_image(A_normal)
|
|
|
62 |
return textured_image
|
63 |
|
64 |
def gradio_interface(A, A_normal, B):
|
65 |
+
"""Gradio interface function to texture images."""
|
66 |
textured_image = texture_image_with_normal(A, A_normal, B)
|
67 |
return np.array(textured_image)
|
68 |
|