jounery-d commited on
Commit
93e8fc6
·
verified ·
1 Parent(s): a3abce7

Upload 7 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip 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
 
 
 
 
 
 
33
  *.zip 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
+ images/00_00.png filter=lfs diff=lfs merge=lfs -text
37
+ images/01_00.png filter=lfs diff=lfs merge=lfs -text
38
+ images/02_00.png filter=lfs diff=lfs merge=lfs -text
39
+ images/result.png filter=lfs diff=lfs merge=lfs -text
40
+ model/codeformer.axmodel filter=lfs diff=lfs merge=lfs -text
images/00_00.png ADDED

Git LFS Details

  • SHA256: 2e9c3b35169236b196c650c0e87ecdc3cf7d22b359118942ad7d9558ec27d4d1
  • Pointer size: 131 Bytes
  • Size of remote file: 226 kB
images/01_00.png ADDED

Git LFS Details

  • SHA256: 680175179756e717dd8a74191db9254a1be31ae2c0cc9db6bf1d384a68e7efa9
  • Pointer size: 131 Bytes
  • Size of remote file: 232 kB
images/02_00.png ADDED

Git LFS Details

  • SHA256: 45874a18d658e57799e2b63c0e0cf40770e0fb1d89a18b91a3c75e7a3314c9f2
  • Pointer size: 131 Bytes
  • Size of remote file: 315 kB
images/result.png ADDED

Git LFS Details

  • SHA256: 56a4cc8e73ad00ccceb322ae04ba715bcd428de19c84863dc980baf2e2367513
  • Pointer size: 132 Bytes
  • Size of remote file: 2.22 MB
model/codeformer.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd97c1ec3b2fb0927c375c2b3d8e149137fa34e668e6d164654e3933a8d9fd88
3
+ size 94975113
python/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ numpy
2
+ opencv-python
python/run_axmodel.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ import cv2
4
+ import numpy as np
5
+ import axengine as axe
6
+
7
+ def from_numpy(x):
8
+ return x if isinstance(x, np.ndarray) else np.array(x)
9
+
10
+ def main(args):
11
+ # Initialize the model
12
+ session = axe.InferenceSession(args.model_path)
13
+ output_names = [x.name for x in session.get_outputs()]
14
+ input_name = session.get_inputs()[0].name
15
+
16
+ # results
17
+ os.makedirs(args.output_path, exist_ok=True)
18
+
19
+ files =[f for f in os.listdir(args.inputs_path) if f.lower().endswith(('.jpg', '.png', 'jpeg'))]
20
+
21
+ for file in files:
22
+ ori_image = cv2.imread(os.path.join(args.inputs_path, file))
23
+ h, w = ori_image.shape[:2]
24
+ image = cv2.resize(ori_image, (512, 512))
25
+ image = (image[..., ::-1] /255.0).astype(np.float32)
26
+
27
+ mean = [0.5, 0.5, 0.5]
28
+ std = [0.5, 0.5, 0.5]
29
+ image = ((image - mean) / std).astype(np.float32)
30
+
31
+ #image = (image /1.0).astype(np.float32)
32
+ img = np.transpose(np.expand_dims(np.ascontiguousarray(image), axis=0), (0,3,1,2))
33
+
34
+ # Use the model to generate super-resolved images
35
+ sr = session.run(output_names, {input_name: img})
36
+
37
+ #sr_y_image = imgproc.array_to_image(sr)
38
+ sr = np.transpose(sr[0].squeeze(0), (1,2,0))
39
+ sr = (sr*std + mean).astype(np.float32)
40
+
41
+ # Save image
42
+ ndarr = np.clip((sr*255.0), 0, 255.0).astype(np.uint8)
43
+ out_image = cv2.resize(ndarr[..., ::-1], (w, h))
44
+
45
+ cv2.imwrite(f'{arg.output_path}/{file}', out_image)
46
+ print(f"SR image save to `{file}`")
47
+
48
+
49
+ if __name__ == "__main__":
50
+ parser = argparse.ArgumentParser(description="Using the model generator super-resolution images.")
51
+ parser.add_argument("--inputs_path",
52
+ type=str,
53
+ default="images",
54
+ help="origin image path.")
55
+ parser.add_argument("--output_path",
56
+ type=str,
57
+ default="results",
58
+ help="colorized image path.")
59
+ parser.add_argument("--model_path",
60
+ type=str,
61
+ default="./codeformer.axmoel",
62
+ help="model path.")
63
+ args = parser.parse_args()
64
+
65
+ main(args)