zheqiushui commited on
Commit
e3513f8
·
verified ·
1 Parent(s): 8798c9d

Upload 19 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ 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
+ bin/aarch64/test_sr filter=lfs diff=lfs merge=lfs -text
37
+ bin/x86_64/test_sr filter=lfs diff=lfs merge=lfs -text
38
+ edsr_x2_128.axmodel filter=lfs diff=lfs merge=lfs -text
39
+ lib/aarch64/libsr.so filter=lfs diff=lfs merge=lfs -text
40
+ lib/gradio_demo.jpg filter=lfs diff=lfs merge=lfs -text
41
+ lib/x86_64/libsr.so filter=lfs diff=lfs merge=lfs -text
bin/aarch64/test_ax_api ADDED
Binary file (82.4 kB). View file
 
bin/aarch64/test_axcl_api ADDED
Binary file (82.5 kB). View file
 
bin/aarch64/test_enum_devices ADDED
Binary file (19.3 kB). View file
 
bin/aarch64/test_sr ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be1bf087a6018e31f5b4c17c02d1887d98f2e6cd9d3e292f0e48c22939b62e6e
3
+ size 5706312
bin/x86_64/test_ax_api ADDED
Binary file (91.6 kB). View file
 
bin/x86_64/test_axcl_api ADDED
Binary file (91.7 kB). View file
 
bin/x86_64/test_enum_devices ADDED
Binary file (16.8 kB). View file
 
bin/x86_64/test_sr ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85c62a92ae91224cf4332d905b1f9bfcd04914c757372d05a7ef5e378c324f98
3
+ size 4947088
edsr_x2_128.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77997756612342ed8e422be4c47bbe9bf04511bdc5483d3d953d188e5018ddb9
3
+ size 1469507
include/ax_devices.h ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef __AX_DEVICES_H__
2
+ #define __AX_DEVICES_H__
3
+
4
+ #if defined(__cplusplus)
5
+ extern "C"
6
+ {
7
+ #endif
8
+ #define AX_DEVICES_COUNT 16
9
+ #define AX_VERSION_LEN 32
10
+
11
+ typedef enum
12
+ {
13
+ ax_dev_errcode_failed = -1,
14
+ ax_dev_errcode_success = 0,
15
+
16
+ ax_dev_errcode_sysinit_failed,
17
+ ax_dev_errcode_sysdeinit_failed,
18
+ ax_dev_errcode_axcl_sysinit_failed,
19
+ ax_dev_errcode_axcl_sysdeinit_failed,
20
+ } ax_dev_errcode_e;
21
+
22
+ typedef enum
23
+ {
24
+ unknown_device = 0,
25
+ host_device = 1,
26
+ axcl_device = 2
27
+ } ax_devive_e;
28
+
29
+ typedef struct
30
+ {
31
+ struct
32
+ {
33
+ char available;
34
+ char version[AX_VERSION_LEN];
35
+ struct
36
+ {
37
+ int remain;
38
+ int total;
39
+ } mem_info;
40
+ } host;
41
+
42
+ struct
43
+ {
44
+ char host_version[AX_VERSION_LEN];
45
+ char dev_version[AX_VERSION_LEN];
46
+ unsigned char count;
47
+ struct
48
+ {
49
+ int temp;
50
+ int cpu_usage;
51
+ int npu_usage;
52
+ struct
53
+ {
54
+ int remain;
55
+ int total;
56
+ } mem_info;
57
+ } devices_info[AX_DEVICES_COUNT];
58
+
59
+ } devices;
60
+ } ax_devices_t;
61
+
62
+ int ax_dev_enum_devices(ax_devices_t *devices);
63
+ int ax_dev_sys_init(ax_devive_e dev_type, char devid);
64
+ int ax_dev_sys_deinit(ax_devive_e dev_type, char devid);
65
+
66
+ /**
67
+ * @brief 当设备初始化后,申请设备内存
68
+ * 当devid>=0,则虚拟地址为host地址(用作对称),物理地址为设备地址
69
+ * 当devid=-1,则虚拟地址和物理地址都为CMM地址
70
+ *
71
+ * @param devid 设备id
72
+ * @param size 内存大小
73
+ * @param pVirAddr 虚拟地址
74
+ * @param phyAddr 物理地址
75
+ * @return int
76
+ */
77
+ int ax_dev_malloc(char devid, int size, void **pVirAddr, unsigned long long int *phyAddr);
78
+
79
+ /**
80
+ * @brief 当设备初始化后,释放设备内存
81
+ *
82
+ * @param devid 设备id
83
+ * @param pVirAddr 虚拟地址
84
+ * @param phyAddr 物理地址
85
+ * @return int
86
+ */
87
+ int ax_dev_free(char devid, void *pVirAddr, unsigned long long int phyAddr);
88
+
89
+ /**
90
+ * @brief 当设备初始化后,将内存从源地址复制到目标地址(注意,加速卡内存拷贝不会将ax_dev_malloc申请的host内存进行同步,需要用户自己进行同步)
91
+ * src和dst都是host内存,则执行memcpy
92
+ * src为host内存,而dst为设备内存,则执行 host2dev memcpy
93
+ * dst为host内存,而src为设备内存,则执行 dev2host memcpy
94
+ * src和dst都是设备内存,则执行dev2dev memcpy(仅支持同设备id内 memcpy)
95
+ *
96
+ *
97
+ * @param devid 设备id
98
+ * @param pSrcVirAddr 源虚拟地址
99
+ * @param SrcphyAddr 源物理地址,如果为0,则认为为host的内存
100
+ * @param pDstVirAddr 目标虚拟地址
101
+ * @param DstphyAddr 目标物理地址,如果为0,则认为为host的内存
102
+ * @param size 内存大小
103
+ * @return int
104
+ */
105
+ int ax_dev_memcpy(char devid, void *pSrcVirAddr, unsigned long long int SrcphyAddr, void *pDstVirAddr, unsigned long long int DstphyAddr, int size);
106
+
107
+ /**
108
+ * @brief 当设备初始化后,将内存设置为指定值
109
+ *
110
+ * @param devid 设备id
111
+ * @param pVirAddr 虚拟地址
112
+ * @param phyAddr 物理地址
113
+ * @param value 值
114
+ * @param size 内存大小
115
+ * @return int
116
+ */
117
+ int ax_dev_memset(char devid, void *pVirAddr, unsigned long long int phyAddr, int value, int size);
118
+
119
+ #if defined(__cplusplus)
120
+ }
121
+ #endif
122
+
123
+ #endif // __AX_DEVICES_H__
include/ax_sr.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef _AX_SR_H_
2
+ #define _AX_SR_H_
3
+
4
+ #if defined(__cplusplus)
5
+ extern "C"
6
+ {
7
+ #endif
8
+ #include "ax_devices.h"
9
+
10
+ typedef struct
11
+ {
12
+ ax_devive_e dev_type; // Device type
13
+ char devid; // axcl device ID
14
+ char model_path[256];
15
+ } ax_sr_init_param_t;
16
+
17
+ typedef struct
18
+ {
19
+ int width;
20
+ int height;
21
+
22
+ void *pVirAddr;
23
+ } ax_sr_image_t;
24
+
25
+ typedef void *ax_sr_handle_t;
26
+
27
+ int ax_sr_init(ax_sr_init_param_t *param, ax_sr_handle_t *handle);
28
+ int ax_sr_deinit(ax_sr_handle_t handle);
29
+
30
+ int ax_sr_get_scale(ax_sr_handle_t handle);
31
+
32
+ int ax_sr_run(ax_sr_handle_t handle, ax_sr_image_t *input, ax_sr_image_t *output);
33
+
34
+ #if defined(__cplusplus)
35
+ }
36
+ #endif
37
+
38
+ #endif
lib/aarch64/libsr.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:374146847484b9c421e5d85688122c93f5389edccaf195851d3a7d15c3c0fd8c
3
+ size 3274264
lib/example.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pysr import SR
2
+ from pyaxdev import enum_devices, sys_init, sys_deinit, AxDeviceType
3
+ import cv2
4
+ import argparse
5
+
6
+ if __name__ == '__main__':
7
+ parser = argparse.ArgumentParser()
8
+ parser.add_argument('--model', type=str, default='edsr_x2_small_1.axmodel')
9
+ parser.add_argument('--image', type=str)
10
+ args = parser.parse_args()
11
+
12
+ devices_info = enum_devices()
13
+ dev_type = None
14
+ devid = None
15
+ print("可用设备:", devices_info)
16
+ if devices_info['host']['available']:
17
+ print("host device available")
18
+ sys_init(AxDeviceType.host_device, -1)
19
+ dev_type = AxDeviceType.host_device
20
+ devid = -1
21
+ elif devices_info['devices']['count'] > 0:
22
+ print("axcl device available, use device-0")
23
+ sys_init(AxDeviceType.axcl_device, 0)
24
+ dev_type = AxDeviceType.axcl_device
25
+ devid = 0
26
+ else:
27
+ raise Exception("No available device")
28
+
29
+ sr = SR({
30
+ 'dev_type': dev_type,
31
+ 'devid': devid,
32
+ 'model_path': args.model
33
+ })
34
+ image = cv2.imread(args.image)
35
+ sr_image = sr(image)
36
+ cv2.imwrite('sr_image.jpg', sr_image)
37
+
38
+ if devices_info['host']['available']:
39
+ sys_deinit(AxDeviceType.host_device, -1)
40
+ elif devices_info['devices']['count'] > 0:
41
+ sys_deinit(AxDeviceType.axcl_device, 0)
lib/gradio_demo.jpg ADDED

Git LFS Details

  • SHA256: 6824190715d191f132a1fae0b5065eade8d193ed218893bf092e694d1ce02acc
  • Pointer size: 131 Bytes
  • Size of remote file: 329 kB
lib/gradio_example.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from pysr import SR
3
+ from pyaxdev import enum_devices, sys_init, sys_deinit, AxDeviceType
4
+ import argparse
5
+
6
+ if __name__ == '__main__':
7
+ parser = argparse.ArgumentParser()
8
+ parser.add_argument('--model', type=str, default='edsr_x2_small_1.axmodel')
9
+ args = parser.parse_args()
10
+
11
+ devices_info = enum_devices()
12
+ dev_type = None
13
+ devid = None
14
+ print("可用设备:", devices_info)
15
+ if devices_info['host']['available']:
16
+ print("host device available")
17
+ sys_init(AxDeviceType.host_device, -1)
18
+ dev_type = AxDeviceType.host_device
19
+ devid = -1
20
+ elif devices_info['devices']['count'] > 0:
21
+ print("axcl device available, use device-0")
22
+ sys_init(AxDeviceType.axcl_device, 0)
23
+ dev_type = AxDeviceType.axcl_device
24
+ devid = 0
25
+ else:
26
+ raise Exception("No available device")
27
+
28
+ sr = SR({
29
+ 'dev_type': dev_type,
30
+ 'devid': devid,
31
+ 'model_path': args.model
32
+ })
33
+
34
+
35
+
36
+ def run_super_resolution(image):
37
+ # image 是 numpy 数组 (H, W, 3),BGR 格式
38
+ if image is None:
39
+ return None
40
+ sr_image = sr(image)
41
+ return (image, sr_image) # 返回两个图,给ImageComparator显示
42
+
43
+ with gr.Blocks() as demo:
44
+ gr.Markdown("## 图像超分对比 Demo")
45
+ with gr.Row():
46
+ with gr.Column(scale=1):
47
+ input_image = gr.Image(label="上传图片", type="numpy")
48
+ run_button = gr.Button("运行超分")
49
+ with gr.Column(scale=4):
50
+ output_comparator = gr.ImageSlider(height=800)
51
+
52
+ run_button.click(fn=run_super_resolution, inputs=input_image, outputs=output_comparator)
53
+
54
+
55
+ # 启动
56
+ ip = "0.0.0.0"
57
+ demo.launch(server_name=ip, server_port=7860)
58
+
59
+
60
+
61
+ import atexit
62
+ if devices_info['host']['available']:
63
+ atexit.register(lambda: sys_deinit(AxDeviceType.host_device, -1))
64
+ elif devices_info['devices']['count'] > 0:
65
+ atexit.register(lambda: sys_deinit(AxDeviceType.axcl_device, 0))
66
+
67
+
lib/pyaxdev.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import os
3
+ import platform
4
+
5
+ def check_error(code: int) -> None:
6
+ if code != 0:
7
+ raise Exception(f"API错误: {code}")
8
+
9
+ base_dir = os.path.dirname(__file__)
10
+ arch = platform.machine()
11
+
12
+ if arch == 'x86_64':
13
+ arch_dir = 'x86_64'
14
+ elif arch in ('aarch64', 'arm64'):
15
+ arch_dir = 'aarch64'
16
+ else:
17
+ raise RuntimeError(f"Unsupported architecture: {arch}")
18
+
19
+ so_name = "libsr.so"
20
+ lib_paths = [
21
+ os.path.join(base_dir, arch_dir, so_name),
22
+ os.path.join(base_dir, so_name),
23
+ os.path.join("../build/", so_name),
24
+ os.path.join("../build_aarch64/", so_name)
25
+ ]
26
+
27
+ last_error = None
28
+ diagnostic_shown = set()
29
+
30
+ for lib_path in lib_paths:
31
+ try:
32
+ print(f"Trying to load: {lib_path}")
33
+ _lib = ctypes.CDLL(lib_path)
34
+ print(f"✅ Successfully loaded: {lib_path}")
35
+ break
36
+ except OSError as e:
37
+ last_error = e
38
+ err_str = str(e)
39
+ print(f"\n❌ Failed to load: {lib_path}")
40
+ print(f" {err_str}")
41
+
42
+ # Only show GLIBCXX tip once
43
+ if "GLIBCXX" in err_str and "not found" in err_str:
44
+ if "missing_glibcxx" not in diagnostic_shown:
45
+ diagnostic_shown.add("missing_glibcxx")
46
+ print("🔍 Detected missing GLIBCXX version in libstdc++.so.6")
47
+ print("💡 This usually happens when your environment (like Conda) uses an older libstdc++")
48
+ print(f"👉 Try running with system libstdc++ preloaded:")
49
+ print(f" export LD_PRELOAD=/usr/lib/{arch_dir}-linux-gnu/libstdc++.so.6\n")
50
+ elif "No such file" in err_str:
51
+ if "file_not_found" not in diagnostic_shown:
52
+ diagnostic_shown.add("file_not_found")
53
+ print("🔍 File not found. Please verify that libclip.so exists and the path is correct.\n")
54
+ elif "wrong ELF class" in err_str:
55
+ if "elf_mismatch" not in diagnostic_shown:
56
+ diagnostic_shown.add("elf_mismatch")
57
+ print("🔍 ELF class mismatch — likely due to architecture conflict (e.g., loading x86_64 .so on aarch64).")
58
+ print(f"👉 Run `file {lib_path}` to verify the binary architecture.\n")
59
+ else:
60
+ if "generic_error" not in diagnostic_shown:
61
+ diagnostic_shown.add("generic_error")
62
+ print("📎 Tip: Use `ldd` to inspect missing dependencies:")
63
+ print(f" ldd {lib_path}\n")
64
+ else:
65
+ raise RuntimeError(f"\n❗ Failed to load libclip.so.\nLast error:\n{last_error}")
66
+
67
+
68
+ # 定义枚举类型
69
+ class AxDeviceType(ctypes.c_int):
70
+ unknown_device = 0
71
+ host_device = 1
72
+ axcl_device = 2
73
+
74
+ # 定义结构体
75
+ class AxMemInfo(ctypes.Structure):
76
+ _fields_ = [
77
+ ('remain', ctypes.c_int),
78
+ ('total', ctypes.c_int)
79
+ ]
80
+
81
+ class AxHostInfo(ctypes.Structure):
82
+ _fields_ = [
83
+ ('available', ctypes.c_char),
84
+ ('version', ctypes.c_char * 32),
85
+ ('mem_info', AxMemInfo)
86
+ ]
87
+
88
+ class AxDeviceInfo(ctypes.Structure):
89
+ _fields_ = [
90
+ ('temp', ctypes.c_int),
91
+ ('cpu_usage', ctypes.c_int),
92
+ ('npu_usage', ctypes.c_int),
93
+ ('mem_info', AxMemInfo)
94
+ ]
95
+
96
+ class AxDevices(ctypes.Structure):
97
+ _fields_ = [
98
+ ('host', AxHostInfo),
99
+ ('host_version', ctypes.c_char * 32),
100
+ ('dev_version', ctypes.c_char * 32),
101
+ ('count', ctypes.c_ubyte),
102
+ ('devices_info', AxDeviceInfo * 16)
103
+ ]
104
+
105
+
106
+ _lib.ax_dev_enum_devices.argtypes = [ctypes.POINTER(AxDevices)]
107
+ _lib.ax_dev_enum_devices.restype = ctypes.c_int
108
+
109
+ _lib.ax_dev_sys_init.argtypes = [AxDeviceType, ctypes.c_char]
110
+ _lib.ax_dev_sys_init.restype = ctypes.c_int
111
+
112
+ _lib.ax_dev_sys_deinit.argtypes = [AxDeviceType, ctypes.c_char]
113
+ _lib.ax_dev_sys_deinit.restype = ctypes.c_int
114
+
115
+ def enum_devices() -> dict:
116
+ devices = AxDevices()
117
+ check_error(_lib.ax_dev_enum_devices(ctypes.byref(devices)))
118
+
119
+ return {
120
+ 'host': {
121
+ 'available': bool(devices.host.available[0]),
122
+ 'version': devices.host.version.decode('utf-8'),
123
+ 'mem_info': {
124
+ 'remain': devices.host.mem_info.remain,
125
+ 'total': devices.host.mem_info.total
126
+ }
127
+ },
128
+ 'devices': {
129
+ 'host_version': devices.host_version.decode('utf-8'),
130
+ 'dev_version': devices.dev_version.decode('utf-8'),
131
+ 'count': devices.count,
132
+ 'devices_info': [{
133
+ 'temp': dev.temp,
134
+ 'cpu_usage': dev.cpu_usage,
135
+ 'npu_usage': dev.npu_usage,
136
+ 'mem_info': {
137
+ 'remain': dev.mem_info.remain,
138
+ 'total': dev.mem_info.total
139
+ }
140
+ } for dev in devices.devices_info[:devices.count]]
141
+ }
142
+ }
143
+
144
+
145
+ def sys_init(dev_type: AxDeviceType = AxDeviceType.axcl_device, devid: int = 0) -> None:
146
+ check_error(_lib.ax_dev_sys_init(dev_type, devid))
147
+
148
+
149
+ def sys_deinit(dev_type: AxDeviceType = AxDeviceType.axcl_device, devid: int = 0) -> None:
150
+ check_error(_lib.ax_dev_sys_deinit(dev_type, devid))
lib/pysr.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import numpy as np
3
+ from pyaxdev import _lib, AxDeviceType, AxDevices, check_error
4
+
5
+
6
+ class SRInit(ctypes.Structure):
7
+ _fields_ = [
8
+ ('dev_type', AxDeviceType),
9
+ ('devid', ctypes.c_char),
10
+ ('model_path', ctypes.c_char * 256)
11
+ ]
12
+
13
+ class SRImage(ctypes.Structure):
14
+ _fields_ = [
15
+ ('width', ctypes.c_int),
16
+ ('height', ctypes.c_int),
17
+ ('pVirAddr', ctypes.POINTER(ctypes.c_ubyte))
18
+ ]
19
+
20
+
21
+ _lib.ax_sr_init.argtypes = [ctypes.POINTER(SRInit), ctypes.POINTER(ctypes.c_void_p)]
22
+ _lib.ax_sr_init.restype = ctypes.c_int
23
+
24
+ _lib.ax_sr_deinit.argtypes = [ctypes.c_void_p]
25
+ _lib.ax_sr_deinit.restype = ctypes.c_int
26
+
27
+ _lib.ax_sr_run.argtypes = [ctypes.c_void_p, ctypes.POINTER(SRImage), ctypes.POINTER(SRImage)]
28
+ _lib.ax_sr_run.restype = ctypes.c_int
29
+
30
+
31
+ class SR:
32
+ def __init__(self, init_info: dict):
33
+ self.handle = None
34
+ self.init_info = SRInit()
35
+
36
+ # 设置初始化参数
37
+ self.init_info.dev_type = init_info.get('dev_type', AxDeviceType.axcl_device)
38
+ self.init_info.devid = init_info.get('devid', 0)
39
+ setattr(self.init_info, 'model_path', init_info['model_path'].encode('utf-8'))
40
+
41
+ handle = ctypes.c_void_p()
42
+ check_error(_lib.ax_sr_init(ctypes.byref(self.init_info), ctypes.byref(handle)))
43
+ self.handle = handle
44
+
45
+ def __del__(self):
46
+ if self.handle:
47
+ _lib.ax_sr_deinit(self.handle)
48
+
49
+ def __call__(self, image_data: np.ndarray) -> None:
50
+ image = SRImage()
51
+ image.width = image_data.shape[1]
52
+ image.height = image_data.shape[0]
53
+ image.pVirAddr = ctypes.cast(image_data.ctypes.data, ctypes.POINTER(ctypes.c_ubyte))
54
+
55
+ np_sr_image = np.zeros((image.height*2, image.width*2, 3), dtype=np.uint8)
56
+ sr_image = SRImage()
57
+ sr_image.width = image.width*2
58
+ sr_image.height = image.height*2
59
+ sr_image.pVirAddr = ctypes.cast(np_sr_image.ctypes.data, ctypes.POINTER(ctypes.c_ubyte))
60
+
61
+ check_error(_lib.ax_sr_run(self.handle, ctypes.byref(image), ctypes.byref(sr_image)))
62
+ return np_sr_image
lib/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio
lib/x86_64/libsr.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e97d880bb5af1d11bf9cf34f25fb0d346b7aaa4a53df22a80835fa09391eecff
3
+ size 3730592