moyanwang
commited on
Commit
•
0b8d882
1
Parent(s):
5507be0
support super res
Browse files- .gitattributes +6 -0
- demo.py +3 -3
- lyraSD/__pycache__/inference.cpython-38.pyc +0 -0
- lyraSD/inference.py +2 -1
- lyraSD/muse_trt/__pycache__/sd_img2img.cpython-38.pyc +0 -0
- lyraSD/muse_trt/__pycache__/sd_text2img.cpython-38.pyc +0 -0
- lyraSD/muse_trt/__pycache__/utilities.cpython-38.pyc +0 -0
- lyraSD/muse_trt/sd_img2img.py +7 -4
- lyraSD/muse_trt/sd_text2img.py +9 -7
- lyraSD/muse_trt/utilities.py +2 -0
- output/img2img_demo.jpg +0 -0
- output/text2img_demo.jpg +0 -0
- sd1.5-engine/{superx4.plan → superx4-512-512.plan} +2 -2
.gitattributes
CHANGED
@@ -38,3 +38,9 @@ sd1.5-engine/superx4.plan filter=lfs diff=lfs merge=lfs -text
|
|
38 |
sd1.5-engine/unet_fp16.plan filter=lfs diff=lfs merge=lfs -text
|
39 |
sd1.5-engine/vae-decoder.plan filter=lfs diff=lfs merge=lfs -text
|
40 |
sd1.5-engine/vae-encoder.plan filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
sd1.5-engine/unet_fp16.plan filter=lfs diff=lfs merge=lfs -text
|
39 |
sd1.5-engine/vae-decoder.plan filter=lfs diff=lfs merge=lfs -text
|
40 |
sd1.5-engine/vae-encoder.plan filter=lfs diff=lfs merge=lfs -text
|
41 |
+
sd1.5-engine/scheduler filter=lfs diff=lfs merge=lfs -text
|
42 |
+
sd1.5-engine/superx4-512-512.plan filter=lfs diff=lfs merge=lfs -text
|
43 |
+
sd1.5-engine/text_encoder filter=lfs diff=lfs merge=lfs -text
|
44 |
+
sd1.5-engine/tokenizer filter=lfs diff=lfs merge=lfs -text
|
45 |
+
sd1.5-engine/vae filter=lfs diff=lfs merge=lfs -text
|
46 |
+
sd1.5-engine/feature_extractor filter=lfs diff=lfs merge=lfs -text
|
demo.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
from lyraSD import LyraSD
|
2 |
|
3 |
t2imodel = LyraSD("text2img", "./sd1.5-engine")
|
4 |
-
t2imodel.inference(prompt="A fantasy landscape, trending on artstation", use_super=
|
5 |
|
6 |
|
7 |
from PIL import Image
|
8 |
i2imodel = LyraSD("img2img", "./sd1.5-engine")
|
9 |
-
demo_img = Image.open("output/
|
10 |
i2imodel.inference(prompt="A fantasy landscape, trending on artstation",
|
11 |
-
image=demo_img)
|
12 |
|
|
|
1 |
from lyraSD import LyraSD
|
2 |
|
3 |
t2imodel = LyraSD("text2img", "./sd1.5-engine")
|
4 |
+
t2imodel.inference(prompt="A fantasy landscape, trending on artstation", use_super=True)
|
5 |
|
6 |
|
7 |
from PIL import Image
|
8 |
i2imodel = LyraSD("img2img", "./sd1.5-engine")
|
9 |
+
demo_img = Image.open("output/img2img_input.jpg")
|
10 |
i2imodel.inference(prompt="A fantasy landscape, trending on artstation",
|
11 |
+
image=demo_img, use_super=True)
|
12 |
|
lyraSD/__pycache__/inference.cpython-38.pyc
CHANGED
Binary files a/lyraSD/__pycache__/inference.cpython-38.pyc and b/lyraSD/__pycache__/inference.cpython-38.pyc differ
|
|
lyraSD/inference.py
CHANGED
@@ -78,7 +78,8 @@ class LyraSD(object):
|
|
78 |
|
79 |
|
80 |
for i in range(result_image.shape[0]):
|
81 |
-
result_image =
|
|
|
82 |
result_image.save(os.path.join(save_dir, save_basename + "-{}.jpg".format(i)))
|
83 |
|
84 |
return result_image
|
|
|
78 |
|
79 |
|
80 |
for i in range(result_image.shape[0]):
|
81 |
+
result_image = Image.fromarray(result_image[0])
|
82 |
+
result_image = result_image.resize((512, 512))
|
83 |
result_image.save(os.path.join(save_dir, save_basename + "-{}.jpg".format(i)))
|
84 |
|
85 |
return result_image
|
lyraSD/muse_trt/__pycache__/sd_img2img.cpython-38.pyc
CHANGED
Binary files a/lyraSD/muse_trt/__pycache__/sd_img2img.cpython-38.pyc and b/lyraSD/muse_trt/__pycache__/sd_img2img.cpython-38.pyc differ
|
|
lyraSD/muse_trt/__pycache__/sd_text2img.cpython-38.pyc
CHANGED
Binary files a/lyraSD/muse_trt/__pycache__/sd_text2img.cpython-38.pyc and b/lyraSD/muse_trt/__pycache__/sd_text2img.cpython-38.pyc differ
|
|
lyraSD/muse_trt/__pycache__/utilities.cpython-38.pyc
CHANGED
Binary files a/lyraSD/muse_trt/__pycache__/utilities.cpython-38.pyc and b/lyraSD/muse_trt/__pycache__/utilities.cpython-38.pyc differ
|
|
lyraSD/muse_trt/sd_img2img.py
CHANGED
@@ -84,10 +84,8 @@ class TRTStableDiffusionImg2ImgPipeline:
|
|
84 |
|
85 |
self.super = SuperX4TRTInfer(
|
86 |
engine_dir,
|
87 |
-
model_name='superx4.plan',
|
88 |
fp16=True,
|
89 |
-
o_height=o_height,
|
90 |
-
o_width=o_width
|
91 |
)
|
92 |
|
93 |
def runEngine(self, model_name, feed_dict):
|
@@ -359,7 +357,12 @@ class TRTStableDiffusionImg2ImgPipeline:
|
|
359 |
|
360 |
# 10. SuperX4 Resolution, Optional.
|
361 |
if use_super:
|
362 |
-
image =
|
|
|
|
|
|
|
|
|
|
|
363 |
|
364 |
return image
|
365 |
|
|
|
84 |
|
85 |
self.super = SuperX4TRTInfer(
|
86 |
engine_dir,
|
87 |
+
model_name='superx4-512-512.plan',
|
88 |
fp16=True,
|
|
|
|
|
89 |
)
|
90 |
|
91 |
def runEngine(self, model_name, feed_dict):
|
|
|
357 |
|
358 |
# 10. SuperX4 Resolution, Optional.
|
359 |
if use_super:
|
360 |
+
image = np.ascontiguousarray(np.transpose(image, (0, 3, 1, 2))).astype(np.float16)
|
361 |
+
#image = self.super.infer(np.transpose(image.astype(np.float16), (0, 3, 1, 2)))
|
362 |
+
image = self.super.infer(image)
|
363 |
+
image = np.uint8(np.transpose(image, (0, 2, 3, 1)))
|
364 |
+
else:
|
365 |
+
image = np.uint8(image)
|
366 |
|
367 |
return image
|
368 |
|
lyraSD/muse_trt/sd_text2img.py
CHANGED
@@ -58,11 +58,9 @@ class TRTStableDiffusionText2ImgPipeline:
|
|
58 |
self.stream = cuda.Stream()
|
59 |
|
60 |
self.super = SuperX4TRTInfer(
|
61 |
-
engine_dir,
|
62 |
-
model_name='superx4.plan',
|
63 |
-
fp16=True
|
64 |
-
o_height=o_height,
|
65 |
-
o_width=o_width
|
66 |
)
|
67 |
|
68 |
def runEngine(self, model_name, feed_dict):
|
@@ -285,6 +283,10 @@ class TRTStableDiffusionText2ImgPipeline:
|
|
285 |
|
286 |
# 9. SuperX4 Resolution, Optional.
|
287 |
if use_super:
|
288 |
-
image =
|
289 |
-
image = np.transpose(image, (0,3,1,2))
|
|
|
|
|
|
|
|
|
290 |
return image
|
|
|
58 |
self.stream = cuda.Stream()
|
59 |
|
60 |
self.super = SuperX4TRTInfer(
|
61 |
+
engine_dir=engine_dir,
|
62 |
+
model_name='superx4-512-512.plan',
|
63 |
+
fp16=True
|
|
|
|
|
64 |
)
|
65 |
|
66 |
def runEngine(self, model_name, feed_dict):
|
|
|
283 |
|
284 |
# 9. SuperX4 Resolution, Optional.
|
285 |
if use_super:
|
286 |
+
image = np.ascontiguousarray(np.transpose(image, (0, 3, 1, 2))).astype(np.float16)
|
287 |
+
#image = self.super.infer(np.transpose(image.astype(np.float16), (0, 3, 1, 2)))
|
288 |
+
image = self.super.infer(image)
|
289 |
+
image = np.uint8(np.transpose(image, (0, 2, 3, 1)))
|
290 |
+
else:
|
291 |
+
image = np.uint8(image)
|
292 |
return image
|
lyraSD/muse_trt/utilities.py
CHANGED
@@ -534,3 +534,5 @@ def save_image(images, image_path_dir, image_name_prefix):
|
|
534 |
image_path = os.path.join(image_path_dir, image_name_prefix+str(i+1)+'-'+str(random.randint(1000, 9999))+'.png')
|
535 |
print(f"Saving image {i+1} / {images.shape[0]} to: {image_path}")
|
536 |
Image.fromarray(images[i]).save(image_path)
|
|
|
|
|
|
534 |
image_path = os.path.join(image_path_dir, image_name_prefix+str(i+1)+'-'+str(random.randint(1000, 9999))+'.png')
|
535 |
print(f"Saving image {i+1} / {images.shape[0]} to: {image_path}")
|
536 |
Image.fromarray(images[i]).save(image_path)
|
537 |
+
|
538 |
+
|
output/img2img_demo.jpg
CHANGED
output/text2img_demo.jpg
CHANGED
sd1.5-engine/{superx4.plan → superx4-512-512.plan}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b4c37b1fa1a9966104975398cf7b4b4a3ed722335ccde47145c9eb8316030797
|
3 |
+
size 10211800
|