def bibi(self): url = "https://passport.bilibili.com/login" self.browser.get(url) xpath = '//*[@id="login-username"]' self.wait.until(EC.presence_of_element_located( (By.XPATH, xpath))).send_keys('Python') xpath = '//*[@id="login-passwd"]' self.wait.until(EC.presence_of_element_located( (By.XPATH, xpath))).send_keys('Python') xpath = '//*[@id="geetest-wrap"]/div/div[5]/a[1]' self.click(xpath) xpath = '/html/body/div[2]/div[2]/div[6]/div/div/div[2]/div[1]/div/div[2]/img' logo = self.wait.until( EC.presence_of_element_located((By.XPATH, xpath))) f = logo.get_attribute('src') if f: res = requests.get(f) res = res.content with open(f"bilbil.jpg", 'wb') as f: f.write(res) res = demo.run_click("bilbil.jpg") plan = demo.to_selenium(res) X, Y = logo.location['x'], logo.location['y'] print(X, Y) lan_x = 259 / 334 lan_y = 290 / 384 for p in plan: x, y = p['place'] ActionChains(self.browser).move_by_offset( X - 40 + x * lan_x, Y + y * lan_y).click().perform() ActionChains(self.browser).move_by_offset( -(X - 40 + x * lan_x), -(Y + y * lan_y)).perform() # 将鼠标位置恢复到移动前 time.sleep(0.5) xpath = "/html/body/div[2]/div[2]/div[6]/div/div/div[3]/a/div" self.click(xpath) time.sleep(1) try: self.click(xpath) with open("bilbil.jpg", 'rb') as f: data = f.read() with open(f"error2/{int(time.time())}.jpg", 'wb') as f: f.write(data) except: self.ture += 1 demo.draw("bilbil.jpg", res) print(res) print(plan) print("".join([i['text'] for i in plan]))
img = img[:, :, ::-1] inp = tf.convert_to_tensor(img[None], tf.float32) inp = tf.concat([inp, inp], 0) outs = model(inp, training=False) num = outs["valid_detections"].numpy()[1] boxes = outs["nmsed_boxes"].numpy()[1] scores = outs["nmsed_scores"].numpy()[1] classes = outs["nmsed_classes"].numpy()[1] for i in range(num): box = boxes[i] # if scores[i] < 0.5: # continue # box = boxes[i] * np.array([height, width, height, width]) c = classes[i] + 1 print(box, c) img = draw(img, box, c, scores[i], coco_id_mapping, random_color(int(c))) cv2.imshow("img", img) cv2.waitKey(0) cv2.destroyAllWindows() tf.saved_model.save( model.detector, "/home/bail/Data/data2/pretrained_weights/%s" % torch_weight_name) model.save_weights("/home/bail/Data/data2/pretrained_weights/%s.h5" % torch_weight_name)