+
+
+ You can’t perform that action at this time.
+
+
+
+
+
+
+
+
+
+
+
+
+ You signed in with another tab or window. Reload to refresh your session.
+ You signed out in another tab or window. Reload to refresh your session.
+
+
+
+ You can’t perform that action at this time.
+
+
+
+
+
+
+
+
+
+
+
+
+ You signed in with another tab or window. Reload to refresh your session.
+ You signed out in another tab or window. Reload to refresh your session.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/jupyter.py b/src/jupyter.py
new file mode 100644
index 0000000..4209413
--- /dev/null
+++ b/src/jupyter.py
@@ -0,0 +1,11 @@
+# %%
+import pandas as pd
+import numpy as np
+import matplotlib.pyplot as plt
+
+
+ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
+ts = ts.cumsum()
+ts.plot()
+
+# %%
diff --git a/src/paddleHub/bilibili_reviews_clawler.py b/src/paddleHub/bilibili_reviews_clawler.py
new file mode 100644
index 0000000..169d84c
--- /dev/null
+++ b/src/paddleHub/bilibili_reviews_clawler.py
@@ -0,0 +1,59 @@
+import argparse
+import requests as rs
+import random
+import time
+from tqdm import tqdm
+
+# bilibili_reviews_crawler
+parser = argparse.ArgumentParser()
+parser.add_argument('--url', type=str, help='bilibili video url')
+parser.add_argument('--output_file', type=str, default='./reviews.txt', help='reviews output file')
+args = parser.parse_args()
+
+
+video_api_base = 'http://api.bilibili.com/x/web-interface/view?bvid={}'
+reviews_api_base = 'https://api.bilibili.com/x/v2/reply?callback=jQueryjsonp=jsonp&pn={}&type=1&oid={}&sort=0'
+sub_reviews_api_base = 'https://api.bilibili.com/x/v2/reply/reply?callback=jQueryjsonp=jsonp&pn={}&type=1&oid={}&ps=10&root={}'
+def fetch_reviews(url: str, output_file: str):
+ # get old id from bvid
+ bvid = url.split('/')[-1]
+ r = rs.get(video_api_base.format(bvid)).json()
+ aid = r['data']['aid']
+
+ # get reivews info
+ r = rs.get(reviews_api_base.format(1, aid)).json()
+ rcount = int(r['data']['page']['count'])
+ page_size = int(r['data']['page']['size'])
+
+ # fetch reivews
+ n_reviews = 0
+ with open(output_file, 'w') as f:
+ for i in tqdm(range(1, (rcount-1)//page_size+2)):
+ time.sleep(random.random())
+ r = rs.get(reviews_api_base.format(i, aid)).json()
+ replies = r['data']['replies']
+
+ # print(f'page {i}, start to fetch content...')
+ for j, reply in enumerate(replies):
+ #print(f'*****************{j+1}*****************')
+ #print(reply['content']['message'])
+ f.write(repr(reply['content']['message']).replace("'", "") + '\n')
+
+ rpid, sub_rcount, sub_page_size = reply['rpid'], int(reply['rcount']), 10
+ n_reviews += 1+sub_rcount
+
+ if sub_rcount == 0: # no sub replies
+ continue
+
+ for k in range(1, (sub_rcount-1)//sub_page_size+2):
+ sub_r = rs.get(sub_reviews_api_base.format(k, aid, rpid)).json()
+ sub_replies = sub_r['data']['replies']
+ for sub_reply in sub_replies:
+ #print('\t' + sub_reply['content']['message'])
+ f.write(repr(sub_reply['content']['message']).replace("'", "") + '\n')
+
+ print(f'total reviews count: {n_reviews}')
+
+
+if __name__ == "__main__":
+ fetch_reviews(args.url, args.output_file)
\ No newline at end of file
diff --git a/src/paddleHub/chinese_ocr_db_crnn.py b/src/paddleHub/chinese_ocr_db_crnn.py
new file mode 100644
index 0000000..641d5a9
--- /dev/null
+++ b/src/paddleHub/chinese_ocr_db_crnn.py
@@ -0,0 +1,18 @@
+import requests
+import json
+import cv2
+import base64
+
+def cv2_to_base64(image):
+ data = cv2.imencode('.jpg', image)[1]
+ return base64.b64encode(data.tobytes()).decode('utf8')
+
+# 发送HTTP请求
+data = {'images':[cv2_to_base64(cv2.imread("d:/words.jpg"))]}
+headers = {"Content-type": "application/json"}
+url = "http://127.0.0.1:8866/predict/chinese_ocr_db_crnn_server"
+r = requests.post(url=url, headers=headers, data=json.dumps(data))
+
+# 打印预测结果
+print(r.json()["results"])
+print(r.json())
\ No newline at end of file
diff --git a/src/paddleHub/chinese_ocr_db_crnn_hub.py b/src/paddleHub/chinese_ocr_db_crnn_hub.py
new file mode 100644
index 0000000..7901810
--- /dev/null
+++ b/src/paddleHub/chinese_ocr_db_crnn_hub.py
@@ -0,0 +1,10 @@
+import paddlehub as hub
+import cv2
+
+ocr = hub.Module(name="chinese_ocr_db_crnn_server")
+result = ocr.recognize_text(images=[cv2.imread('d:/words.jpg')])
+
+# or
+# result = ocr.recognize_text(paths=['/PATH/TO/IMAGE'])
+# 打印预测结果
+print(result)
\ No newline at end of file