Spaces:
Sleeping
Sleeping
fix error
Browse files- stylegan_generator.py +2 -3
stylegan_generator.py
CHANGED
|
@@ -1,16 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
-
import io
|
| 3 |
import math
|
| 4 |
import numpy as np
|
| 5 |
import onnxruntime as ort
|
| 6 |
from PIL import Image
|
| 7 |
-
import gradio as gr
|
| 8 |
|
| 9 |
LATENT_FEATURES = 512
|
| 10 |
RESOLUTION = 256
|
| 11 |
LAST_INDEX = math.log2(RESOLUTION) - 2
|
| 12 |
|
| 13 |
MODEL_PATH = os.path.join("model", "batik_stylegan.onnx")
|
|
|
|
| 14 |
|
| 15 |
alpha = np.array([1.0], dtype=np.float32)
|
| 16 |
steps = np.array([LAST_INDEX], dtype=np.int64)
|
|
@@ -30,4 +29,4 @@ def generate_stylegan():
|
|
| 30 |
image = np.transpose(image, (1, 2, 0))
|
| 31 |
pil_img = Image.fromarray(image, 'RGB')
|
| 32 |
|
| 33 |
-
return pil_img.resize((512, 512), Image.LANCZOS)
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import math
|
| 3 |
import numpy as np
|
| 4 |
import onnxruntime as ort
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
|
| 7 |
LATENT_FEATURES = 512
|
| 8 |
RESOLUTION = 256
|
| 9 |
LAST_INDEX = math.log2(RESOLUTION) - 2
|
| 10 |
|
| 11 |
MODEL_PATH = os.path.join("model", "batik_stylegan.onnx")
|
| 12 |
+
model = ort.InferenceSession(MODEL_PATH)
|
| 13 |
|
| 14 |
alpha = np.array([1.0], dtype=np.float32)
|
| 15 |
steps = np.array([LAST_INDEX], dtype=np.int64)
|
|
|
|
| 29 |
image = np.transpose(image, (1, 2, 0))
|
| 30 |
pil_img = Image.fromarray(image, 'RGB')
|
| 31 |
|
| 32 |
+
return pil_img.resize((512, 512), Image.LANCZOS)
|