ryland 2 лет назад
Родитель
Сommit
abb952f172

+ 88 - 36
tasks/Hyakkiyakou/agent/agent.py

@@ -6,9 +6,13 @@ import numpy as np
 from datetime import datetime
 from pathlib import Path
 from numpy import uint8, fromfile
+from cached_property import cached_property
 
 from oashya.tracker import Tracker
+from oashya.labels import CLASSINDEX as CI
+from oashya.labels import id2label, id2name
 from module.logger import logger
+from tasks.Hyakkiyakou.agent.focus import Focus
 
 
 def generate_gaussian_patch(size=(300, 300), mean=0, std_dev=60):
@@ -42,38 +46,36 @@ def embed_patch_in_canvas(canvas, patch, position=(0, 0), patch_size=(300, 300))
     return canvas
 
 
-
-
 class Agent:
     GAUSSIAN = generate_gaussian_patch()
-    MIN_BUFF: int = 0
-    MAX_BUFF: int = 6
-    MIN_N: int = 7
-    MAX_N: int = 18
-    MIN_G: int = 19
-    MAX_G: int = 35
-    MIN_R: int = 36
-    MAX_R: int = 72
-    MIN_SR: int = 73
-    MAX_SR: int = 137
-    MIN_SSR: int = 138
-    MAX_SSR: int = 183
-    MIN_SP: int = 184
-    MAX_SP: int = 218
-    BUFF_001 = 0
-    BUFF_002 = 1
-    BUFF_003 = 2
-    BUFF_004 = 3
-    BUFF_005 = 4
-    BUFF_006 = 5
-    BUFF_007 = 6
+    OBSERVE_THRESHOLD = 0.6
+    # --------------------------------------------------------------------------------
+
+    def __init__(self, strategy: dict = None):
+        self.z = np.zeros((720, 1280), dtype=np.float32)
+        self.focus: Focus = None
+        # 
+        strategy: dict = strategy if strategy is not None else {
+            # 'weights': [1., 1., 1., 0.6, 0.3, 0.3],
+            'priorities': [],
+            'invite_friend': False,
+            'auto_bean': False
+        }
+        self.strategy = strategy
+        self.weights: list[float] = strategy.get('weights', [1., 1., 0.7, 0.3, 0., 0.])
+        self.priorities: list[int] = strategy.get('priorities', [])
+        self.invite_friend: bool = strategy.get('invite_friend', False)
+        self.auto_bean: bool = strategy.get('auto_bean', False)
+        #
+        self.last_throw_time = datetime.now()
+        self.dbg_throw: int = 0
+        self.dbg_throw_n: int = 0
 
     @classmethod
     def gamma(cls, tracks: list[tuple],
-              weights: list[float] = [1., 1., 1., .6, 0.3, 0.3],
+              weights: list[float],
               priorities: list[int] = []) -> np.ndarray:
         """
-
         @param tracks:
         @param weights: sp, ssr, sr, r, n, g
         @param priorities:
@@ -82,18 +84,68 @@ class Agent:
         z = np.zeros((720, 1280), dtype=np.float32)
         for _id, _class, _conf, _cx, _cy, _w, _h, _v in tracks:
             weight = 1.
+            mu = 0.8 + (_cx * 0.2) / 1280
             match _class:
-                case _ if cls.MIN_G <= _class <= cls.MAX_G: weight = weights[5]
-                case _ if cls.MIN_N <= _class <= cls.MAX_N: weight = weights[4]
-                case _ if cls.MIN_R <= _class <= cls.MAX_R: weight = weights[3]
-                case _ if cls.MIN_SR <= _class <= cls.MAX_SR: weight = weights[2]
-                case _ if cls.MIN_SSR <= _class <= cls.MAX_SSR: weight = weights[1]
-                case _ if cls.MIN_SP <= _class <= cls.MAX_SP: weight = weights[0]
-                case cls.BUFF_005: weight = -1.  # freeze
-            z = embed_patch_in_canvas(canvas=z, patch=weight * Agent.GAUSSIAN, position=(_cx, _cy))
+                case _ if CI.MIN_G <= _class <= CI.MAX_G: weight = weights[5]
+                case _ if CI.MIN_N <= _class <= CI.MAX_N: weight = weights[4]
+                case _ if _class != CI.R_008 and _class != CI.R_007 and (CI.MIN_R <= _class <= CI.MAX_R):
+                    weight = weights[3]  # 不要童男童女
+                case _ if CI.MIN_SR <= _class <= CI.MAX_SR: weight = weights[2]
+                case _ if CI.MIN_SSR <= _class <= CI.MAX_SSR: weight = 1.5 * weights[1]
+                case _ if CI.MIN_SP <= _class <= CI.MAX_SP: weight = 1.5 * weights[0]
+                case CI.BUFF_005: weight = -1.  # freeze
+                case _: continue
+            if weight == 0.:
+                continue
+            z = embed_patch_in_canvas(canvas=z, patch=(mu * weight) * Agent.GAUSSIAN, position=(_cx, _cy))
         return z
 
-
-
-
+    @classmethod
+    def argmax_gamma(cls, z: np.ndarray, tracks: list[tuple]) -> Focus:
+        max_y, max_x = np.unravel_index(np.argmax(z), z.shape)
+        max_variance = 2000
+        max_index = -1
+        for index, track in enumerate(tracks):
+            _id, _class, _conf, _cx, _cy, _w, _h, _v = track
+            variance = (max_x - _cx)**2 + (max_y - _cy)**2
+            if variance < max_variance:
+                max_index = index
+                max_variance = variance
+        return Focus(inputs=tracks[max_index])
+
+    def decision(self, tracks: list[tuple], state: list):
+        not_decision = [-1, -1, False, -1]
+        if not tracks:
+            return not_decision
+        # Cache the time interval for scattering beans
+        new_time = datetime.now()
+        delta_time = 1000 * (new_time - self.last_throw_time).total_seconds()  # ms
+        self.check_observe(tracks=tracks)
+        if self.focus is None:
+            return not_decision
+        result = self.focus.decision(tracks=tracks, strategy=self.strategy, state=[delta_time] + state)
+        if result[2]:
+            self.last_throw_time = new_time
+            self.dbg_throw += 1
+        else:
+            self.dbg_throw_n += 1
+        return result
+
+    def check_observe(self, tracks: list[tuple]):
+        z = Agent.gamma(tracks=tracks, weights=self.weights, priorities=self.priorities)
+        focus = Agent.argmax_gamma(z=z, tracks=tracks)
+        omega = focus.omega(z)
+        if omega < self.OBSERVE_THRESHOLD:
+            if self.focus is not None:
+                logger.info(f'Focus disappear')
+            self.focus = None
+            return
+        if self.focus is None or self.focus != focus:
+            logger.info(f'Focus changed, now: {id2name(focus._class)}')
+            self.focus = focus
+            self.focus.set_omega(omega)
+        elif self.focus == focus:
+            self.focus.update(focus)
+            self.focus.set_omega(omega)
+        # self.focus.show()
 

+ 115 - 0
tasks/Hyakkiyakou/agent/focus.py

@@ -0,0 +1,115 @@
+import numpy as np
+
+from rich.table import Table
+from rich.text import Text
+from cached_property import cached_property
+
+from module.logger import logger
+
+from oashya.labels import id2label, id2name
+from oashya.labels import CLASSINDEX as CI
+
+
+class Focus:
+    def __init__(self, inputs: list[tuple]):
+        self._id: int = inputs[0]
+        self._class: int = inputs[1]
+        self._conf: int = inputs[2]
+        self._cx: int = inputs[3]
+        self._cy: int = inputs[4]
+        self._w: int = inputs[5]
+        self._h: int = inputs[6]
+        self._v: float = inputs[7]
+        # -----------------------
+        self._omega: float = 0.
+        self._omega_buff: float = 0.
+
+    def __eq__(self, o):
+        return self._id == o._id or o._class == self._class
+
+    def __str__(self):
+        return f"""
+id: {self._id}
+class: {self._class}
+label: {id2label(self._class)}
+name: {id2name(self._class)}
+conf: {self._conf}
+xywh: ({self._cx}, {self._cy}, {self._w}, {self._h})
+velocity: {self._v}"""
+
+    def omega(self, z):
+        __omega = z[self._cy, self._cx]
+        self._omega = __omega
+        return __omega
+
+    def set_omega(self, value):
+        self._omega = value
+
+    def show(self):
+        table = Table(show_lines=True)
+        table.add_column('Property', header_style="bright_cyan", style="cyan", no_wrap=True)
+        table.add_column("Value", style="green")
+        table.add_column('Property', header_style="bright_cyan", style="cyan", no_wrap=True)
+        table.add_column("Value", style="green")
+        table.add_row('id', str(self._id), 'conf', str(self._conf))
+        table.add_row('class', str(self._class), 'xywh', f'({self._cx}, {self._cy}, {self._w}, {self._h})')
+        table.add_row('label', id2label(self._class), 'velocity', str(self._v))
+        table.add_row('name', f'{id2name(self._class)}', 'omega', str(self._omega))
+        logger.print(table, justify='center')
+
+    def update(self, focus):
+        self._id = focus._id
+        self._class = focus._class
+        self._conf = focus._conf
+        self._cx = focus._cx
+        self._cy = focus._cy
+        self._w = focus._w
+        self._h = focus._h
+        self._v = focus._v
+
+    def decision(self, tracks, strategy, state) -> list:
+
+        buff_omega, buff_cx, buff_cy, buff_v, buff_class = self.omega_buff(tracks, strategy['invite_friend'])
+        self._omega_buff = buff_omega
+        buffed: bool = True if self._omega_buff > self._omega else False
+        omega = max(self._omega, self._omega_buff)
+        _r = self.r(vector=state, omega=self._omega, omega_buff=self._omega_buff)
+        throw = True if _r > 0 else False
+        # x, y, throw, number
+        return [0, 0, throw, 10]
+
+    def omega_buff(self, tracks, invite_friend: bool) -> float:
+        max_omega = 0.
+        max_cx = 0
+        max_cy = 0
+        max_v = 0
+        max_class = 0
+
+        for _id, _class, _conf, _cx, _cy, _w, _h, _v in tracks:
+            _current_omega = 0.
+            match _class:
+                case CI.BUFF_004: _current_omega = 2.2
+                case CI.BUFF_006: _current_omega = 2.0
+                case CI.BUFF_007: _current_omega = 2.0 if invite_friend and _cx <= 1000 else 0
+                case CI.BUFF_002: _current_omega = 2.0 if self._omega >= 1.5 else 0
+                case CI.BUFF_003: _current_omega = 2.0 if self._omega >= 1.5 else 0
+                case CI.BUFF_003: _current_omega = 2.0 if self._omega >= 1.5 and _cx <= 640 else 0
+                case _: pass
+            if _current_omega > max_omega:
+                max_omega = _current_omega
+                max_cx = _cx
+                max_cy = _cy
+                max_v = _v
+                max_class = _class
+        return max_omega, max_cx, max_cy, max_v, max_class
+            
+    @classmethod
+    def r(cls, vector: list, omega: float, omega_buff: float) -> float:
+        _omega = max(omega, omega_buff)
+        tau = - 140 / (vector[0] - 100)
+        upsilon = (vector[1] / 250 - vector[2] / 35)
+        upsilon = 100 * (upsilon**2 if upsilon > 0 else - upsilon**2)
+        result = _omega + tau + upsilon - 0.6
+        print(f"total: {result:.4f} | {_omega:.4f} | {tau:.4f} | {upsilon:.4f} | ")
+        return result
+

+ 5 - 0
tasks/Hyakkiyakou/agent/utils.py

@@ -0,0 +1,5 @@
+
+
+
+
+

+ 4 - 4
tasks/Hyakkiyakou/assets.py

@@ -61,17 +61,17 @@ class HyakkiyakouAssets:
 
 	# Image Rule Assets
 	# description 
-	I_RESF_0 = RuleImage(roi_front=(615,14,30,46), roi_back=(615,14,30,46), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_0.png")
+	I_RESF_0 = RuleImage(roi_front=(615,13,30,46), roi_back=(606,11,43,51), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_0.png")
 	# description 
 	I_RESF_1 = RuleImage(roi_front=(617,13,31,46), roi_back=(610,11,42,50), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_1.png")
 	# description 
-	I_RESF_2 = RuleImage(roi_front=(615,15,33,47), roi_back=(612,11,39,52), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_2.png")
+	I_RESF_2 = RuleImage(roi_front=(611,14,33,47), roi_back=(602,10,47,57), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_2.png")
 	# description 
 	I_RESF_3 = RuleImage(roi_front=(619,14,28,45), roi_back=(610,12,40,49), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_3.png")
 	# description 
-	I_RESF_4 = RuleImage(roi_front=(613,14,37,47), roi_back=(613,14,37,47), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_4.png")
+	I_RESF_4 = RuleImage(roi_front=(611,14,37,47), roi_back=(608,14,43,47), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_4.png")
 	# description 
-	I_RESF_5 = RuleImage(roi_front=(612,10,35,48), roi_back=(612,10,35,48), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_5.png")
+	I_RESF_5 = RuleImage(roi_front=(612,10,35,48), roi_back=(612,10,35,48), threshold=0.9, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_5.png")
 	# description 
 	I_RESF_6 = RuleImage(roi_front=(616,10,29,49), roi_back=(616,10,29,49), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_resf_6.png")
 	# description 

+ 9 - 10
tasks/Hyakkiyakou/debugger.py

@@ -23,28 +23,27 @@ def test_track(show: bool = False):
     folder_save = Path('./tasks/Hyakkiyakou/temp/save')
     shutil.rmtree(folder_save, ignore_errors=True)
     folder_save.mkdir(parents=True, exist_ok=True)
-    folder_image = Path('./tasks/Hyakkiyakou/temp/20240526T103931')
+    folder_image = Path('./tasks/Hyakkiyakou/temp/20240621T221325')
     #
     start_time = datetime.now()
     for index, file in enumerate(folder_image.iterdir()):
         print(f'{index}-----------------------------------------------------------------------------------------------')
         if file.suffix != '.png':
             continue
-        img = cv2.imdecode(fromfile(str(file), dtype=uint8), -1)
-        image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+        image = cv2.imdecode(fromfile(str(file), dtype=uint8), -1)
+        # image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
         results = tracker(image=image)
         print(results)
         save_file = folder_save / f'{file.stem}.png'
         draw_image = draw_tracks(image, results)
         if show:
             cv2.imshow('OAS Tracker', draw_image)
-            cv2.waitKey(1000)
-            time.sleep(2)
+            cv2.waitKey(500)
             print('Press any key to continue')
         else:
             cv2.imwrite(str(save_file), draw_image)
-        if index >= 4:
-            raise
+        # if index >= 14:
+        #     raise
     end_time = datetime.now()
     print(f'平均时间: {(end_time - start_time) / len([folder_image.iterdir()])}')
 
@@ -97,13 +96,13 @@ class Debugger:
 def test_debugger():
     debugger = Debugger()
     debugger.show_start()
-    folder_image = Path('./tasks/Hyakkiyakou/temp/20240526T103931')
+    folder_image = Path('./tasks/Hyakkiyakou/temp/20240621T221325')
     for index, file in enumerate(folder_image.iterdir()):
         print(f'{index}-----------------------------------------------------------------------------------------------')
         if file.suffix != '.png':
             continue
-        img = cv2.imdecode(fromfile(str(file), dtype=uint8), -1)
-        image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
+        image = cv2.imdecode(fromfile(str(file), dtype=uint8), -1)
+        # image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
         debugger.show_sync(image)
         time.sleep(0.1)
     debugger.show_stop()

+ 7 - 7
tasks/Hyakkiyakou/hya/image3.json

@@ -2,8 +2,8 @@
   {
     "itemName": "resf_0",
     "imageName": "hya_resf_0.png",
-    "roiFront": "615,14,30,46",
-    "roiBack": "615,14,30,46",
+    "roiFront": "615,13,30,46",
+    "roiBack": "606,11,43,51",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -20,8 +20,8 @@
   {
     "itemName": "resf_2",
     "imageName": "hya_resf_2.png",
-    "roiFront": "615,15,33,47",
-    "roiBack": "612,11,39,52",
+    "roiFront": "611,14,33,47",
+    "roiBack": "602,10,47,57",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -38,8 +38,8 @@
   {
     "itemName": "resf_4",
     "imageName": "hya_resf_4.png",
-    "roiFront": "613,14,37,47",
-    "roiBack": "613,14,37,47",
+    "roiFront": "611,14,37,47",
+    "roiBack": "608,14,43,47",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -50,7 +50,7 @@
     "roiFront": "612,10,35,48",
     "roiBack": "612,10,35,48",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.9,
     "description": "description"
   },
   {

+ 6 - 2
tasks/Hyakkiyakou/script_task.py

@@ -71,11 +71,15 @@ class ScriptTask(GameUi, HyaSlave):
 if __name__ == '__main__':
     # from module.config.config import Config
     # from module.device.device import Device
-    from debugger import test_track
 
     # c = Config('oas1')
     # d = Device(c)
 
     # t = ScriptTask(c, d)
     # t.run()
-    test_track(show=True)
+    from tasks.Hyakkiyakou.agent.tagent import test_observe, test_state
+    test_state()
+    # from debugger import test_track
+    # test_track(show=False)
+    pass
+

+ 46 - 16
tasks/Hyakkiyakou/slave/hya_slave.py

@@ -38,12 +38,17 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
     UNIT0HUNDRED: list[int] = [146, 647, 18, 25]
     DECADE0DECADE: list[int] = [126, 647, 18, 25]
     UNIT0DECADE: list[int] = [140, 647, 18, 25]
+    UNIT0: list[int] = [132, 647, 18, 25]
     # buff
     BUFF_ROI1: list[int] = [150, 1, 150, 50]
     BUFF_ROI2: list[int] = [320, 1, 140, 50]
     BUFF_ROI3: list[int] = [840, 1, 150, 50]
     BUFF_ROI4: list[int] = [1100, 1, 140, 50]
 
+    # 剩余豆子数量, 剩余式神数量, 一次砸豆子的数量, 第一个格子, 第二个格子, 第三个格子, 第四个格子
+    slave_state: tuple = [250, 35, 10,
+                          HyaBuff.BUFF_STATE0, HyaBuff.BUFF_STATE0, HyaBuff.BUFF_STATE0, HyaBuff.BUFF_STATE0]
+
     @cached_property
     def res_r(self) -> list[RuleImage]:
         return [
@@ -111,9 +116,11 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
     def predict_res(self, current: int) -> int:
         for i in range(current, current-5, -1):
             unit = i % 10
-            unit_img = self.res_r[unit]
+            unit_img = self.res_r[unit] if i >= 10 else self.res_f[unit]
             if not self.appear(unit_img):
                 continue
+            if i < 10:
+                return i
             decade = i // 10
             decade_img = self.res_f[decade]
             if not self.appear(decade_img):
@@ -138,7 +145,7 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
                     continue
                 return bean
 
-            else:
+            elif bean >= 10:
                 decade = bean // 10
                 decade_img = self.bean[decade]
                 decade_img.roi_back = self.DECADE0DECADE
@@ -154,6 +161,17 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
                     unit_img.roi_back = self.UNIT0DECADE
                     if self.appear(unit_img):
                         return max(0, (bean // 10) * 10 + i)
+            else:
+                unit = bean % 10
+                unit_img = self.bean[unit]
+                unit_img.roi_back = self.UNIT0
+                if self.appear(unit_img):
+                    return bean
+                for i in range(10):
+                    unit_img = self.bean[i]
+                    unit_img.roi_back = self.UNIT0
+                    if self.appear(unit_img):
+                        return max(0, i)
         logger.warning(f'Cannot predict bean, current: {current}')
         return current
 
@@ -208,6 +226,18 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
                 continue
         logger.info('Invite friend done')
 
+    def update_state(self):
+        res_bean = self.predict_bean(self.slave_state[0])
+        res_shi = self.predict_res(self.slave_state[1])
+        num_bean = 5 if self.recognize_bean_05() else 10
+        buff_0 = self.predict_buff_state(pos=0, current=self.slave_state[3])
+        buff_1 = self.predict_buff_state(pos=1, current=self.slave_state[4])
+        buff_2 = self.predict_buff_state(pos=2, current=self.slave_state[5])
+        buff_3 = self.predict_buff_state(pos=3, current=self.slave_state[6])
+        self.slave_state = [
+            res_bean, res_shi, num_bean, buff_0, buff_1, buff_2, buff_3
+        ]
+        return self.slave_state
 
 def covert_rgb():
     images_folders: Path = Path(r'E:\Project\OnmyojiAutoScript\tasks\Hyakkiyakou\temp\20240614T214216')
@@ -228,15 +258,15 @@ def test_predict_res():
     c = Config('oas1')
     d = Device(c)
     hd = HyaSlave(c, d)
-    img = cv2.imread(r'E:\Project\OnmyojiAutoScript\tasks\Hyakkiyakou\temp\save\all1716691199364.png')
+    img = cv2.imread('D:/Project/OnmyojiAutoScript/tasks/Hyakkiyakou/temp/20240621T221325/all1718979259551.png')
     img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
     hd.device.image = img
-    print(hd.predict_res(18))
+    print(hd.predict_res(2))
 
-    def do_test():
-        hd.predict_res(18)
-    execution_time = timeit.timeit(do_test, number=100)
-    print(f"执行总的时间: {execution_time * 1000} ms")
+    # def do_test():
+    #     hd.predict_res(18)
+    # execution_time = timeit.timeit(do_test, number=100)
+    # print(f"执行总的时间: {execution_time * 1000} ms")
     # total time is 36.2ms on my computer /cpu:AMD Ryzen 5 3550H with Radeon Vega Mobile
     # 0.362ms per predict_res
 
@@ -248,14 +278,14 @@ def test_predict_bean():
     c = Config('oas1')
     d = Device(c)
     hd = HyaSlave(c, d)
-    img = cv2.imread(r'E:\Project\OnmyojiAutoScript\tasks\Hyakkiyakou\temp\save14\170.png')
+    img = cv2.imread('./tasks/Hyakkiyakou/temp/20240621T221325/all1718979269677.png')
     img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
     hd.device.image = img
-    print(hd.predict_bean(200))
-    def do_test():
-        hd.predict_bean(180)
-    execution_time = timeit.timeit(do_test, number=100)
-    print(f"执行总的时间: {execution_time * 1000} ms")
+    print(hd.predict_bean(15))
+    # def do_test():
+    #     hd.predict_bean(180)
+    # execution_time = timeit.timeit(do_test, number=100)
+    # print(f"执行总的时间: {execution_time * 1000} ms")
     # total time is 17.9ms on my computer in 100 times
 
 def test_predict_buff():
@@ -279,9 +309,9 @@ if __name__ == '__main__':
     c = Config('oas1')
     d = Device(c)
     hd = HyaSlave(c, d)
-    hd.invite_friend(False)
+    # hd.invite_friend(False)
 
     # test_predict_res()
-    # test_predict_bean()
+    test_predict_bean()
     # test_predict_buff()